A controlled component is an input form element, whose value is controlled by React, that renders a form and also controls what happens in that form on subsequent user input
Q2 Should we wait to store the users responses from the form into state when they submit the form OR should we update the state with their responses as soon as they enter them? Why.
State should be updated as soon as the user enters their responses in the form, both to catch user errors earlier, and because it allows you to pass the value to other UI elements too, or reset it from other event handlers
Create a function that will be called when the user enters or changes text in the input field. Then, inside the event handler, usd event.target.value to access the value of the input field. You can then update your component's state with this value.
A ternary operator can be used to shorten conditional statements.
if(x===y){
console.log(true);
} else {
console.log(false);
}
(x === y) ? console.log(true) : console.log(false)
What does a controlled component look like in practice?