How can I avoid the infinite render loop if I change a state?
Hi! I have a problem that I have a table and I have a custom state to collect the validated cells in a given row.
My problem is that when I call state to set the cell data to be valid I get an infinite loop, because the whole table is rendered and so are the cells and so is the state running in the cell.
Two values I can't check if they change because they will always be the current value because the whole table is rendered again.
As you can see in this example the save is also done on onBlur event but if you take the save logic out of onBlur you get an infinite loop. This is exactly the problem for me that I can't control that only the given cell is rendered but the whole table is re-rendered.
https://codesandbox.io/p/devbox/objective-moon-s2fvrs?file=%2Fsrc%2Fmain.tsx&workspaceId=ab7e9acc-1479-4e18-9b3b-8d4e6cba4023
Is there any workaround to call a state that the table uses in a way that doesn't cause an infinite loop?
3 Replies
stormy-gold•2y ago
by giving columns and data a stable reference
stormy-gold•2y ago

stormy-gold•2y ago