Skip to content

Instantly share code, notes, and snippets.

@maisonm
Created July 6, 2020 16:36
Show Gist options
  • Save maisonm/05492ddb29a6d499c7e4182480f9312b to your computer and use it in GitHub Desktop.
Save maisonm/05492ddb29a6d499c7e4182480f9312b to your computer and use it in GitHub Desktop.
Lifecycle methods
componentDidMount() {
this.determineNumberOfPages();
}
componentDidUpdate(prevProps, prevState) {
const { data, setData } = this.props;
const { currentClickedNumber, pageData } = this.state;
if (data !== prevProps.data) {
this.determineNumberOfPages();
}
if (currentClickedNumber !== prevState.currentClickedNumber) {
setData(pageData[currentClickedNumber]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment