React Docs - Forms
What is a ‘Controlled Component’? State is set initially in the constructor as this.state = {key:value}. The component that renders a component also controls what happens to data sent by way of that component.
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. I don’t understand what this question is asking.
How do we target what the user is entering if we have an event handler on an input field? One can create a variable for name that is target.name. Then, the name prop can be used by the handler to reference the specific field.
The Conditional (Ternary) Operator Explained
Why would we use a ternary operator? Ternary operators allow one to more succinctly construct if/else statements.
Rewrite the following statement using a ternary statement:
if(x===y){
` console.log(true);
} else {
console.log(false);
}`
Rewritten Statement:
console.log(x===y ? true : false);