Skip to content

Instantly share code, notes, and snippets.

@kartikag01
Created August 30, 2018 05:51
Show Gist options
  • Save kartikag01/02c693b9d627b2465b7009b44bedc6b5 to your computer and use it in GitHub Desktop.
Save kartikag01/02c693b9d627b2465b7009b44bedc6b5 to your computer and use it in GitHub Desktop.
react method after change in lifecycle
static getDerivedStateFromProps(nextProps, prevState) {
if (prevState.pageNo !== nextProps.pageNo) {
return { pageNo: nextProps.pageNo };
}
}
componentDidUpdate(prevProps) {
if (prevProps.pageNo !== this.props.pageNo) {
fetchNextPageData(this.props.pageNo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment