I have build a editable grid using data from a JSON Array. While editing a textbox, the focus is lost. I understand that the entire grid is re-rendering and this is expected. I therefore added React.memo to both my Grid and Row components. But the problem still persists. What are the patterns/best practices used in React to handle such scenarois? Thanks!
2
Answers
You have to use defaultValue instead of value on inputs.
When using controllable input, and onChange function together. It would be pointless to use value on the input.
Vercel Playground Link
Here is an updated version from your code its working good for me. if you have any question please ask.
I think the Issue was with the row renders as i told you the input is mounted then un-mounted because you are creating the components inside other components. This is a bad practice.