Skip to the content.

Code 301 Class 04 Reading Notes

React Doc Forms

HTML form elements work a bit differently from other DOM elements in React, because form elements naturally keep some internal state.

  1. What is a ‘Controlled Component’? An input form element whose value is controlled by React in this way
  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. I would want to wait the update the state when the user enters data, so we have the data available to store and utilize.
  3. How do we target what the user is entering if we have an event handler on an input field? By using the value attribute or name attribute to each element.

The Conditional (Ternary) Operator Explained

  1. Why would we use a ternary operator? Less characters for less chances of code breaking. DRY as heck :)
  2. Rewreite the following statement using a ternary statement

Before

if (x===y){
  console.log(true);
} else {
  cosole.log(false)
}

After

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

Things I want to know more about

<—BACK