-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
remove child in an array from beginning, each child's state is not woking as expected #120
Comments
additional to that, this will also cause componentWillMount, componentDidMount and other life cycle hook invoked on incorrect child component |
@eisneim Great work, thanks for investigating this. I think we're going to need to have the component recycling invoke the constructor again when re-using a collected component: This will probably cause some slight performance disadvantages, sadly, since it is now a common pattern to use class instance properties to mimic lexically scoped methods. However, I think it's best to make the recycler as transparent as possible, and this is one case where it currently isn't. Are you able to elaborate on the lifecycle issue you mentioned in your second comment? |
…oking component constructors when re-using components from the recycler.
https://jsfiddle.net/ryan_ou/uLnspcp7/2/ I wrote a jsfiddle for the lifecycle issue: ps. |
@zhenkunou nice work! |
…not a great idea. Babel's transpiled constructors (and basically anything else) re-assign to the prototype, which is slow and a fairly bad idea. Also, and more importantly, it was assigning `this.base` to `null`, completely ignoring the main reason for caching components (caching their generated DOM using the component itself as a cache key). This commit changes the behavior to discard the cached component instance itself, re-using only the base by copying it to a fresh instance. Best of both worlds! /cc @eisneim @zhenkunou
jsfiddle https://jsfiddle.net/eisneim/rrqtpj72/1/
it seems that the props.key is not working, and because of the "component-recycler", the state was not reseted when a child is collected, this will cause issue when child is reused, the previous state object is still there
The text was updated successfully, but these errors were encountered: