Hızlı yanıt: kod örneği
About the removal of : you should be able to handle its uses with a combination of and , see the React blog post for example migrations. And yes, the object returned by updates the state similarly to an object passed to .In case you really need the old value of a prop, you can always cache it in your state with something like this:Anything that doesn't affect the state can be put in , and there's even a for very low-level stuff.UPDATE: To get a feel for the new (and old) lifecycle methods, the react-lifecycle-visualizer package may be helpful.
componentWillReceiveProps
getDerivedStateFromProps
componentDidUpdate
getDerivedStateFromProps
setState
state = { cachedSomeProp: null // ... rest of initial state};static getDerivedStateFromProps(nextProps, prevState) { // do things with nextProps.someProp and prevState.cachedSomeProp return { cachedSomeProp: nextProps.someProp, // ... other derived state properties };}
componentDidUpdate
getSnapshotBeforeUpdate