Controlled Component

ref – https://stackoverflow.com/questions/42522515/what-are-react-controlled-components-and-uncontrolled-components
https://reactjs.org/docs/forms.html#controlled-components

A Controlled Component is one that takes its current value through props and notifies changes through callbacks like onChange. A parent component “controls” it by handling the callback and updating its state. It then passes the updated back to the controlled component. You could also call this a “dumb component”.

The parent component’s hold on that single source of data is called “single source of truth”.

In regards to Elements

1) Since the value attribute is set to display component’s state, the displayed value will always be this.state.value. This makes React state the single source of truth.
2) Since handleChange runs on every keystroke to update the React state, the displayed value will update as the user types.
3) With a controlled component, the input’s value is always driven by the React state.

With a Textarea, we write it like this:

In regards to Components

We have controlled components ListGroup and Pagination. Notice we pass data into them to be processed and displayed. They then use callbacks such as selectedGenre, handlePageChange, handleNoGenre, handleGenreSelect to update parent component Movies’s state.