React State Events And Managed Controls
Here's an example of a React component with a "managed" input field. Whenever the value of the input field changes, an event handler is called which updates the state of the component with the new value of the input field. The call to setState in the event handler will trigger a call to render updating the component in the dom.
Its very important to note the runtime behavior. Every time a user changes the value in the input field
. handleChange will be called and so
.setState will be called and so
.render will be called
Pop quiz, after you type a character in the input field, which DOM elements change
1. all of these - the top level div, legend, input, h1
2. only the input and h1
4. whats a DOM?