-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
componentWillReceiveProps()
does not trigger for new context changes
#5756
Comments
In fact, https://jsfiddle.net/bzytthat/ Read more about using |
I have an implementation that does not work. https://github.com/titon/toolkit/blob/3.0/src/ui/components/carousel/ItemList.js When I add I am using the latest React 0.14. Here's an example of the Carousel in use: https://github.com/titon/toolkit/blob/3.0/src/test.js Edit: Out of curiosity, I added Edit 2: I removed everything from |
I did some debugging in the React source, and it seems to always trigger true for this clause.
Which seems to agree with my original issue, that the |
I have a perfect example of this not working correctly. I added a console log statement to every lifecycle method for each child of
And the console output on initial load.
The order of the events match the order of the elements in the JSX. HOWEVER, if you look closely, you'll notice that And here's the output when you cycle to the next item in the list.
The same thing happens again, |
I tested this using my pull request here: #5776
And here's the output when you cycle to the next item in the list.
So far it works correctly. Still trying to find out why |
Fixed here: #5787 |
The
componentWillReceiveProps()
method only triggers if props change. However, there are situations where the context changes, but the props do not, but this method does not trigger. It makes it really difficult to alter the state before an update, as we can't do this incomponentWillUpdate()
.Perhaps a new method, like
componentWillReceiveContext()
can be added, or the previouscomponentWillReceiveProps()
can simply be renamed to something likecomponentWillReceive()
, which is always called if any prop/state/context has changed.The text was updated successfully, but these errors were encountered: