reading-notes

Class 301.04

Notes

Readings

React Docs - Forms

  1. What is a ‘Controlled Component’?

    An input form element whose value is controlled by React is called a “controlled component” it’s a form element, like an input or textarea, whose value is controlled by the component’s state. The value is set in the state and updated through event handlers, allowing React to be the single source of truth for the form’s value

  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.

    when they submit, otherwise it’ll update every time the user types a letter

  3. How do we target what the user is entering if we have an event handler on an input field?

    The value of the input field can be accessed using event.target.value within the event handler.

The Conditional (Ternary) Operator Explained

  1. Why would we use a ternary operator?

    it’s more concise

  2. Rewrite the following statement using a ternary statement:
Example
if(x===y){
  console.log(true);
} else {
  console.log(false);
}

Answer

console.log(x===y ? true : false)

Things I want to learn more about

React Bootstrap - Forms React Docs - conditional rendering

References