View on GitHub

reading-notes

Learning Notes Repo for Code Fellows

React and Forms

React Docs - Forms

  1. What is a ‘Controlled Component’?
    • it takes its current value through props and notifies changes through callbacks
  2. 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
  3. 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

  1. Why would we use a ternary operator?
    • it shortening the code
  2. 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