reading-notes

Reading Notes for Codefellows

View the Project on GitHub kylecohen14/reading-notes

React and forms

Forms

  1. What is a ‘Controlled Component’?
    • Input form element whose value is controlled by react
  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.
    • update as the user types. Able to pass to other UI elements or reset it from othe event handlers
  3. How do we target what the user is entering if we have an event handler on an input field?
    • add a name attribute

Conditional ternary operator

  1. Why would we use a ternary operator?
    • to make a block of code execute if a certain condition is met
  2. Rewrite the following statement using a ternary statement:

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

Cite