Skip to content

Instantly share code, notes, and snippets.

@a-x-
Last active July 17, 2018 18:16
Show Gist options
  • Save a-x-/634684f6112d5b69c6c8a0b423752972 to your computer and use it in GitHub Desktop.
Save a-x-/634684f6112d5b69c6c8a0b423752972 to your computer and use it in GitHub Desktop.
react temporal state
// Временное выставление статуса
class Foo extends React.PureComponent {
// ...
foo () {
// ...
this.setState({
triggered: setTimeout(() => this.setState({ triggered: null }), 500)
})
}
componentWillUnmount () {
if (this.state.triggered) clearTimeout(this.state.triggered)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment