I dont get the following explanation. Why removing this.state.input from the input element will not do it? To me it seems state is updated even without it. So what?
Now your next step will involve creating an input box and trigger it when someone types anything. Luckily we have an event called
onChange()
to serve this purpose.
But this just won’t serve your purpose. Although you might feel that its working. So what’s happening here is text updates from the browser not the state. So to correct this we’ll add avalue
attribute and set it tothis.state.input
to the input element which will make the input get controlled by state.
Challenge: Create a Controlled Input
Link to the challenge: