{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/5756","labels_url":"https://api.github.com/repos/facebook/react/issues/5756/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/5756/comments","events_url":"https://api.github.com/repos/facebook/react/issues/5756/events","html_url":"https://github.com/facebook/react/issues/5756","id":124391871,"number":5756,"title":"`componentWillReceiveProps()` does not trigger for new context changes","user":{"login":"milesj","id":143744,"avatar_url":"https://avatars.githubusercontent.com/u/143744?v=3","gravatar_id":"","url":"https://api.github.com/users/milesj","html_url":"https://github.com/milesj","followers_url":"https://api.github.com/users/milesj/followers","following_url":"https://api.github.com/users/milesj/following{/other_user}","gists_url":"https://api.github.com/users/milesj/gists{/gist_id}","starred_url":"https://api.github.com/users/milesj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milesj/subscriptions","organizations_url":"https://api.github.com/users/milesj/orgs","repos_url":"https://api.github.com/users/milesj/repos","events_url":"https://api.github.com/users/milesj/events{/privacy}","received_events_url":"https://api.github.com/users/milesj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-30T19:45:30Z","updated_at":"2016-01-05T19:30:48Z","closed_at":null,"body":"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 in `componentWillUpdate()`.\r\n\r\nPerhaps a new method, like `componentWillReceiveContext()` can be added, or the previous `componentWillReceiveProps()` can simply be renamed to something like `componentWillReceive()`, which is always called if any prop/state/context has changed."},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/169105231","html_url":"https://github.com/facebook/react/issues/5756#issuecomment-169105231","issue_url":"https://api.github.com/repos/facebook/react/issues/5756","id":169105231,"user":{"login":"milesj","id":143744,"avatar_url":"https://avatars.githubusercontent.com/u/143744?v=3","gravatar_id":"","url":"https://api.github.com/users/milesj","html_url":"https://github.com/milesj","followers_url":"https://api.github.com/users/milesj/followers","following_url":"https://api.github.com/users/milesj/following{/other_user}","gists_url":"https://api.github.com/users/milesj/gists{/gist_id}","starred_url":"https://api.github.com/users/milesj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milesj/subscriptions","organizations_url":"https://api.github.com/users/milesj/orgs","repos_url":"https://api.github.com/users/milesj/repos","events_url":"https://api.github.com/users/milesj/events{/privacy}","received_events_url":"https://api.github.com/users/milesj/received_events","type":"User","site_admin":false},"created_at":"2016-01-05T19:30:48Z","updated_at":"2016-01-05T19:30:48Z","body":"I tested this using my pull request here: https://github.com/facebook/react/pull/5776\r\n\r\n```\r\nItemList componentWillMount \r\nItem componentWillMount (x9)\r\nTabList componentWillMount \r\nTab componentWillMount (x9)\r\nNext componentWillMount \r\nPrev componentWillMount \r\nStart componentWillMount \r\nStop componentWillMount \r\nItem componentDidMount (x9)\r\nItemList componentDidMount \r\nTab componentDidMount (x9)\r\nTabList componentDidMount \r\nNext componentDidMount \r\nPrev componentDidMount \r\nStart componentDidMount \r\nStop componentDidMount \r\n--------- Updated the state for number of visual items, will render 3 items and 9 tabs ---------\r\nItemList componentWillReceiveContext ***\r\nItemList shouldComponentUpdate \r\nItemList componentWillUpdate \r\nItem componentWillReceiveProps \r\nItem componentWillReceiveContext ***\r\nItem shouldComponentUpdate \r\nItem componentWillUpdate \r\nItem componentWillReceiveProps \r\nItem componentWillReceiveContext ***\r\nItem shouldComponentUpdate \r\nItem componentWillUpdate \r\nItem componentWillReceiveProps \r\nItem componentWillReceiveContext ***\r\nItem shouldComponentUpdate \r\nItem componentWillUpdate \r\nTabList componentWillReceiveContext ***\r\nTabList shouldComponentUpdate \r\nTabList componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nNext componentWillReceiveContext ***\r\nNext shouldComponentUpdate \r\nNext componentWillUpdate \r\nPrev componentWillReceiveContext ***\r\nPrev shouldComponentUpdate \r\nPrev componentWillUpdate \r\nStart componentWillReceiveContext ***\r\nStart shouldComponentUpdate \r\nStart componentWillUpdate \r\nStop componentWillReceiveContext ***\r\nStop shouldComponentUpdate \r\nStop componentWillUpdate \r\nItem componentDidUpdate (x3)\r\nItemList componentDidUpdate \r\nTab componentDidUpdate (x9)\r\nTabList componentDidUpdate \r\nNext componentDidUpdate \r\nPrev componentDidUpdate \r\nStart componentDidUpdate \r\nStop componentDidUpdate \r\n```\r\nAnd here's the output when you cycle to the next item in the list.\r\n```\r\nSyntheticMouseEvent click 1 Object { dispatchConfig: Object, dispatchMarker: \".0.2\", nativeEvent: click, target: <button.carousel-next>, currentTarget: <button.carousel-next>, type: \"click\", eventPhase: 3, bubbles: true, cancelable: true, timeStamp: 492246832, 22 more… } Array [  ] \r\n    \r\nItemList componentWillReceiveContext ***\r\nItemList shouldComponentUpdate \r\nItemList componentWillUpdate \r\nItem componentWillReceiveProps \r\nItem componentWillReceiveContext ***\r\nItem shouldComponentUpdate \r\nItem componentWillUpdate \r\nItem componentWillReceiveProps \r\nItem componentWillReceiveContext ***\r\nItem shouldComponentUpdate \r\nItem componentWillUpdate \r\nItem componentWillMount \r\nTabList componentWillReceiveContext ***\r\nTabList shouldComponentUpdate \r\nTabList componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nTab componentWillReceiveProps \r\nTab componentWillReceiveContext ***\r\nTab shouldComponentUpdate \r\nTab componentWillUpdate \r\nNext componentWillReceiveContext ***\r\nNext shouldComponentUpdate \r\nNext componentWillUpdate \r\nPrev componentWillReceiveContext ***\r\nPrev shouldComponentUpdate \r\nPrev componentWillUpdate \r\nStart componentWillReceiveContext ***\r\nStart shouldComponentUpdate \r\nStart componentWillUpdate \r\nStop componentWillReceiveContext ***\r\nStop shouldComponentUpdate \r\nStop componentWillUpdate \r\nItem componentDidUpdate \r\nItem componentDidMount \r\nItemList componentDidUpdate \r\nTab componentDidUpdate \r\nTabList componentDidUpdate \r\nNext componentDidUpdate \r\nPrev componentDidUpdate \r\nStart componentDidUpdate \r\nStop componentDidUpdate \r\n    \r\nCarousel#6762at6g0kk 3334.095 cycling 1 \r\nCarousel#6762at6g0kk 3334.355 cycled 1 \r\n```\r\nSo far it works correctly. Still trying to find out why `componentWillReceiveProps` isn't."}}