8 ms·
> I know why: it is good practice to feed back any input into the state of the React component so everything is in sync. I used to this. A better approach is t
by nafey 5y ago
> I know why: it is good practice to feed back any input into the state of the React component so everything is in sync.
I used to this. A better approach is to use the onBlur event of the input field to update the text to state. The text itself can be accessed via a reference to the input field in the onBlur event (created with useRef). This makes it so that not every typing action rerenders the whole component.