Re:DaedalOS: Desktop Environment in the Browser
by nafey on Monday January 03, 2022 @10:55AM
(#29781997)
> 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.
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.