Skip to content

Instantly share code, notes, and snippets.

@BartKrol
Last active August 22, 2016 11:59
Show Gist options
  • Save BartKrol/551540b951a8ada3cad5ade0154db1ca to your computer and use it in GitHub Desktop.
Save BartKrol/551540b951a8ada3cad5ade0154db1ca to your computer and use it in GitHub Desktop.
Popover timeout clearing
componentWillReceiveProps(nextProps) {
if (nextProps.open !== this.state.open) {
// (...)
} else {
if (nextProps.animated) {
if (this.timeout !== null) return; // Return if still closing
this.setState({closing: true});
// (...)
componentWillUnmount() {
clearTimeout(this.timeout);
this.timeout = null; // Clear timeout attribute
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment