I have a modal with some input fields. I can easily pass the data automatically with the user typing an input, using onChange
function in the input field, as >
Use controlled component for this situation, define a value
property of input element
like this:
Whenever you will update that variable, automatically that value will get populated in input element.
Now you can populate some default value by assigning a value to variable_name
and user can update that value by onChange
function.
As per DOC:
An input form element whose value is controlled by React in this way is called a "controlled component".