React Practice
When we use React to process form elements, there are generally two ways: controlled components and uncontrolled components.
1. Controlled form component: React binds the state and the form value together, and state value controls the form value, thus ensuring the characteristics of a single data source. First, we need to declare a component's state data and then set it as the value of the input element. Then we add a change event to the input, and in the event handler, we get the value of the current text box through the event object 'e'. Finally, we call the setState method to use the value of the text box as the latest value of the state.
2. The uncontrolled form component obtains the value of the text box by manually manipulating the DOM. The 'state' does not control the state of the text box in the react component, and the input value is obtained directly through the DOM. #programming #jracademy