When using React you have to always use camelCase for naming events.
Regarding the error, the problem lies in handleChange method and the easiest fix is to pass a new state object to this.setState instead of passing updater function. Normally you would pass a function to this.setState when you want to compute next state using previous state. In this challenge however we don’t need previous state, so there is no need for that:
React under the hood uses SyntheticEvent which is just a wrapper around the browser event.
In React 16 and earlier (this challenge uses 16.4) these Synthetic Events are pooled, in other words, they are reused and are no longer available after event handler has been called.
setState() does not immediately mutate the state.
Because of all the above:
handleChange(event) {
// This updater function will not be called immediately,
this.setState(state => ({
// By the time it gets called the event will already be
// pooled - meaning its properties will be nullified
input: event.target.value
});
};
On the other hand:
handleChange(event) {
// Here again the state will not be updated immediately,
// but this time we're passing an object
this.setState({
// and we set its properties when we still have access to
// event object
input: event.target.value
});
};
This is not something that you have to worry about, because from React 17 there is no event pooling anymore.