Created
August 29, 2018 02:50
-
-
Save sal-pal/80e20aec615883fea4c1900c8ce256cf to your computer and use it in GitHub Desktop.
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
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