Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deepDiffer causing lots of Array iteration logspew #868

Closed
ide opened this issue Apr 15, 2015 · 13 comments
Closed

deepDiffer causing lots of Array iteration logspew #868

ide opened this issue Apr 15, 2015 · 13 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ide
Copy link
Contributor

ide commented Apr 15, 2015

See:

Your code is broken! Do not iterate over arrays with for...in. See https://fburl.com/31944000 for more information.

    at Array.Object.defineProperty.Object.defineProperty.get [as __ARRAY_ENUMERATION_GUARD__] (Array.prototype.es6.js:26)
    at Object.deepDiffer [as diff] (deepDiffer.js:39)
    at diffRawProperties (diffRawProperties.js:54)
    at ReactIOSNativeComponent.Mixin.computeUpdatedProperties (ReactIOSNativeComponent.js:150)
    at ReactIOSNativeComponent.Mixin.receiveComponent (ReactIOSNativeComponent.js:189)
    at Object.ReactReconciler.receiveComponent (ReactReconciler.js:97)
    at ReactCompositeComponentMixin._updateRenderedComponent (ReactCompositeComponent.js:726)
    at ReactCompositeComponentMixin._performComponentUpdate (ReactCompositeComponent.js:705)
    at ReactCompositeComponentMixin.updateComponent (ReactCompositeComponent.js:625)
    at ReactPerf.measure.wrapper [as updateComponent] (ReactPerf.js:70)
@dvbportal
Copy link

For me it is unclear why for..in should be considered broken. (The link 'https://fburl.com/31944000' is gone)

I also refactored some of those loops into .forEach(function() {..., but there are some 'this'-related side effects.

@sophiebits
Copy link
Contributor

Sorry, the link goes to an FB-internal page:

image

You can pass this as a second argument to forEach or use an arrow function to preserve the context.

@dvbportal
Copy link

Thanks Ben, for clearing that up. I see now, that it is a good idea to give that warning.

@josebalius
Copy link

@spicyj @dvbportal so guys is this still a bug or is there a proper way to do this? I am having the same error with ListView.

@sophiebits
Copy link
Contributor

Still an issue unfortunately. Should be fixed with the next sync though.

@soheil-zz
Copy link

+1

@romanonthego
Copy link

+1
..and any updates? it's impossible to use many of libraries right now (baobab and typology for example) without monkey patching it.

@sahrens
Copy link
Contributor

sahrens commented Apr 24, 2015

I landed a fix internally that should get sync'd out soon.

On Apr 23, 2015, at 11:54 PM, Roman Dubinin [email protected] wrote:

+1
..and any updates? it's impossible to use many of libraries right now (baobab and typology for example) without monkey patching it.


Reply to this email directly or view it on GitHub.

@ide
Copy link
Contributor Author

ide commented Apr 24, 2015

@sahrens is your fix to make the polyfilled methods non-enumerable? That's the cleanest solution I had in mind since RN is used only in ES5+ environments.

@sahrens
Copy link
Contributor

sahrens commented Apr 24, 2015

My fix just checks Array.isArray in deepDiffer and does the appropriate type of iteration.

On Apr 24, 2015, at 12:15 AM, James Ide [email protected] wrote:

@sahrens is your fix to make the polyfilled methods non-enumerable? That's the cleanest solution I had in mind since RN is used only in ES5+ environments.


Reply to this email directly or view it on GitHub.

@ide
Copy link
Contributor Author

ide commented Apr 24, 2015

Got it - that fix seems right too. For the Array.prototype polyfill I think we want to use Object.defineProperty to add the polyfilled methods as non-enumerable properties. I imagine this was not done consciously for www so is it possible for www and RN to have different copies of the polyfill?

@vjeux
Copy link
Contributor

vjeux commented Apr 24, 2015

It was done consciously for www because we want to have the same behavior with IE8 that doesn't support Object.defineProperty. If we were to use Object.defineProperty, we would break IE8 in a lot of terrible ways as most developers are not testing against IE8. But, you are right, it doesn't seem like a good way to polyfill it in React Native.

@sophiebits
Copy link
Contributor

Fixed in ab1efbd.

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants