reading-notes

React and Forms

What is a ‘Controlled Component’?

A controlled component is a component that renders form elements and controls them by keeping the form data in the component’s state.

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

after adding the setState on the ChangeInput function, we can target the event as event.target.value The Conditional (Ternary) Operator Explained.

Why would we use a ternary operator?

We use the ternary operator because it allows us to assgin one value to a variable that will return either true or false, also because it makes assigning values to variables easier to see and work with, because it’s all on one line.

ex:

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