reading_notes

Read: Class 04 - React and Forms:

Forms

React Forms

What is a ‘Controlled Component’?

A technique that allow JavaScript function to handle submission and access the data from user input.

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.

updating the state with users responses as soon as they enter them is better because this allow to instantly which is faster and prevent lagging and probably problems especially for component’s that’s depends on it.

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

By using event.target.name.


The Conditional (Ternary) Operator

Ternary Operatop

Why would we use a ternary operator?

Using a conditional, like an if statement, allows us to specify that a certain block of code should be executed if a certain condition is met.

While we can show same results in more simple and shorter way using The Conditional (Ternary) Operator Explained.

Example using (if): if ( condition ) { value if true; } else { value if false; }

Ex: using Ternary: condition ? value if true : value if false

Rewrite the following statement using a ternary statement:

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

ternary statement:

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


Things I want to know more about

to know more about forms and how to use it widely in react and make multiform and design a best UI and UX.