Skip to content

Commit

Permalink
Define input state in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
KoolADE85 committed Jul 10, 2023
1 parent 259b63a commit 0198e20
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export default class Input extends PureComponent {
constructor(props) {
super(props);

this.state = {
pendingEvent: undefined,
value: '',
};

this.input = React.createRef();

this.onBlur = this.onBlur.bind(this);
Expand All @@ -33,7 +38,7 @@ export default class Input extends PureComponent {

UNSAFE_componentWillReceiveProps(nextProps) {
const {value} = this.input.current;
if (this.state?.pendingEvent) {
if (this.state.pendingEvent) {
// avoid updating the input while awaiting a debounced event
return;
}
Expand Down

0 comments on commit 0198e20

Please sign in to comment.