reading-notes

Read Class 04

Reading

React Docs - Forms

  1. What is a ‘Controlled Component’?
    • an input form element with a React state being the “single source of truth”. The react component that renders a form also controls what happens in the form on subsequent user inputs.
  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 wtih their responses as soon as they enter them? Why?
    • we should update immediately as this provides a more interactive and responsive user experience.
  3. How do we target what the user is entering if we have an event handler on an input field?
    • We target what the user is entering in an input field by accessing the ‘value’ property of the event object that is passed to the event handler.

The Conditional (Ternary) Operator Explained

  1. Why would we use a ternary operator?
    • ternary operator is a shorthand way to write an ‘if’ statement that returns one value when a condition is true and another value when the condition is false.
  2. Rewrite the following statement using a ternary statement:
    • x === y ? console.log(true) : console.log(false);