Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 1.35 KB

File metadata and controls

38 lines (32 loc) · 1.35 KB

React Forms

Section Source

  • Form elements naturally keep an internal state
    • <input>, <textarea>, <select>
  • Controlled Components - an input form element whose value is controlled by the React state as the "single source of truth"
  • Input values should always be set via controlled components, that way they are updated as the user types in the information on each keystroke and this information is made available for other elements or event handlers. (think fuzzy search)
  • use a state value attribute to controll an imput element

Ternary Operator

Section Source

condition ? value if true : value if false;
  • condition, what you are testing
    • result should always be or coerce to a boolean true or false
  • ternary operators can be nested
  • multiple operations can be run using comma separation
  • use to shorten if statements into single lines of code
Original Code:
  if(x===y){
 console.log(true);
  } else {
 console.log(false);
  }

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

Bookmark/Skim

Bootstrap Forms React Conditional Rendering

Things I want to know more about:

  • TBD