Skip to content

Instantly share code, notes, and snippets.

@sintell
Created March 5, 2019 13:18
Show Gist options
  • Save sintell/4f5b64ed45925f1f8ac2603b06df8626 to your computer and use it in GitHub Desktop.
Save sintell/4f5b64ed45925f1f8ac2603b06df8626 to your computer and use it in GitHub Desktop.
const { showedId, setShow } = this.props.context;
if (
showedId === prevProps.context.showedId &&
this.state.show === prevState.show &&
this.props.show &&
showedId !== this.state.id
) {
setShow(this.state.id);
}
if (showedId === null || this.state.id === null) {
return;
}
if (showedId !== prevProps.context.showedId) {
this.setState(({ id }) => ({
show: showedId === id,
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment