Error at onTableChange passing to state
So i want to set the tableState to my state,
and then it shows me an error =
if you want to try this is my codesandbox https://codesandbox.io/s/zealous-water-brusy?fontsize=14
| Tech | Version |
|---|---|
| Material-UI | |
| MUI-datatables | |
| React | |
| browser | |
| etc |
This is due to the way that react works. You are changing state inside the render function in such a way that it is causing a re-render, which then fires the state change again, and so on...
To fix this, you have to pull your data out of the render function and check the previous state against the new state when you update to make sure you are only updating when there is a change.
Your issue is similar to the one here, about the common mistake of updating state in componentDidUpdate without first checking that the state has changed: https://reactjs.org/docs/react-component.html#componentdidupdate.
can you help me to fix this in my codesandbox ? cause i'm very stuck