Skip to content

Instantly share code, notes, and snippets.

@sal-pal
Created August 29, 2018 02:50
Show Gist options
  • Save sal-pal/80e20aec615883fea4c1900c8ce256cf to your computer and use it in GitHub Desktop.
Save sal-pal/80e20aec615883fea4c1900c8ce256cf to your computer and use it in GitHub Desktop.
class CollapseWrapper extends React.Component {
constructor(props) {
super(props);
}
componentDidUpdate(prevProps) {
const { onOpen, onClose } = this.props
const isShownUpdated = (this.props.isShown !== prevProps.isShown)
const contentOpen = this.props.isShown
if (isShownUpdated) {
if (contentOpen) {
return onOpen()
}
onClose()
}
}
render() {
return (
<Collapse isShown={this.props.isShown} />
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment