Created
July 6, 2020 16:36
-
-
Save maisonm/05492ddb29a6d499c7e4182480f9312b to your computer and use it in GitHub Desktop.
Lifecycle methods
This file contains hidden or 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
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