reading-notes

My reading notes


Project maintained by brandomoki Hosted on GitHub Pages — Theme by mattgraham

React and Forms

  1. What is a ‘Controlled Component’?
    • controlled components usually maintain their own state
  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.
    • because there will be a re-render
  3. How do we target what the user is entering if we have an event handler on an input field?
    • event.target

Conditional (ternary) Operrator

  1. Why would we use a ternary operator?
    • allows you to shorten an if statement to a one liner
  2. Rewrite the following statement using a ternary statement:
    • if(x===y){ console.log(true); } else { console.log(false);

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