Skip to content

Commit

Permalink
Gutenberg: Initialize and remove timer during mounting and unmounting.
Browse files Browse the repository at this point in the history
The timer is used for checking user inputs.

See #13.
  • Loading branch information
r-a-y committed Apr 14, 2020
1 parent d0246cf commit 4dc9f92
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions block.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,19 @@
this.onChange = this.onChange.bind( this );
this.onKeyDown = this.onKeyDown.bind( this );

this.timer = null;

this.state = {
value: props.value
};
}

componentDidMount() {
this.timer = null;
}

componentWillUnmount() {
clearTimeout(this.timer);
}

onChange( event ) {
const inputValue = event.target.value;

Expand Down

0 comments on commit 4dc9f92

Please sign in to comment.