Created
April 11, 2018 08:52
-
-
Save nightspirit/1d878781cc4a1aae5cbf24812851bbd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// before | |
componentWillReceiveProps(nextProps) { | |
if (this.props.currentRow !== nextProps.currentRow) { | |
this.setState({ | |
isScrollingDown: nextProps.currentRow > this.props.currentRow | |
}) | |
} | |
} | |
// after | |
static getDerivedStateFromProps(nextProps, prevState) { | |
if (nextProps.currentRow !== prevState.lastRow) { | |
return { | |
isScrollingDown: nextProps.currentRow > prevState.lastRow, | |
lastRow: nextProps.currentRow | |
} | |
} | |
// Return null to indicate no change to state. | |
return null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment