Use different lifecycle methods for React 16.4 support. #128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
React 16.4 deprecates
componentWillMount
,componentWillReceiveProps
,componentWillUpdate
& renames them toUNSAFE_componentWillMount
,UNSAFE_componentWillRecieveProps
,UNSAFE_componentWillUpdate
.Slider.js
usescomponentWillRecieveProps
andcomponentWillMount
. It however doesn't look like it actually needs to use them!Firstly
_panResponder
is initialized incomponentWillMount
. It feels fairly arbitrary where we initialize this in fact, but the most important thing is that it is initialized before the first render. Moving this intialization to the constructor guarantees this also, and the pan-responder basic usage shows initialization in the constructor, for example: https://facebook.github.io/react-native/docs/panresponder.html#basic-usage.Secondly,
Slider
usescomponentWillReceiveProps
to trigger some animations. Async React will behave differently in the future: https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#side-effects-on-props-changeTherefore I have moved the logic from within
componentWillRecieveProps
tocomponentDidUpdate
. One semantic difference is that this PR uses the current value ofthis.props.animateTransitions
, which will be the current (after the update) prop value ofanimateTransitions
incomponentDidUpdate
whereas incomponentWillReceiveProps
,nextProps
was not checked for this value,this.props
was used, meaning it was not the new value.It seems to me that it's more correct to use the current value of
animateTransitions
after the update, but let me know if you don't think that this is the case!Thirdly....thanks for making & maintaining this great library 🎉🎉🎉