- What is a ‘Controlled Component’?
- it takes its current value through props and notifies changes through callbacks
- 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.
- no, because the input’s value is always driven by the React state
- How do we target what the user is entering if we have an event handler on an input field?
- by adding a name attribute to each element and let the handler function choose what to do based on the value of event.target.name
The Conditional (Ternary) Operator Explained
- Why would we use a ternary operator?
- Rewrite the following statement using a ternary statement:
if(x===y){
console.log(true);
} else {
console.log(false);
}
- ternary:
x===y ? console.log(true) : console.log(false);
more on forms
more on Ternary
<==Back