Reading-Notes

View the Project on GitHub MohammadAl-khatib/Reading-Notes

React and Forms

Forms

Form as a React component behaves in adifferent way than what we saw with HTML forms, all because of its initial state, it is better to use a controlled component to handle React form component.

A controlled component is the one that controls a value from user input, it is used by setting a value in the component state and give the user the power to change it with a function recalled inside onChange, this will give us the ability to update the value from other components and functions, this can be done with input, textarea, and select. For uncontrolled components like input type="file" another approach will be used later in this course.

The Conditional (Ternary) Operator Explained

It is another, and shorer, way for writing conditional syntax, here is an example:

Ternary operator usage image