New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Err: "Maximum update depth exceeded" with version 7.1.0 #2369
Comments
|
I'm also experiencing this with 7.1.0. |
|
Same here. Seems to be happening on all the 7.x versions. |
|
Don't forget to either wrap columns inside useMemo or define columns outside the component.
See Option Memoization for more info. |
|
I seem to be having an issue similar to this, though the error only occurs when a state change happens in a parent component. I have a setup like this: I know this is very simplified and I am not certain that this will help without the context of the code segments I have omitted, but the files are relatively complex and I wasn't sure how else to go about simplifying it. Basically, the onClick (and, more specifically, the subsequent call to setState) triggers this "Maximum update depth exceeded" error. I should note that the setState does not affect any of the props supplied to the Child or Grandchild components. And this behavior only occurs with newer versions. Before, I found that installing react-table version 7.0.0-rc.16 alleviated the problem, but now that I have found a bug with table expansion in IE (which appeared to be fixed in newer versions), this solution is no longer acceptable. Any assistance would be appreciated and I can provide more details if necessary; I'm sort of reaching the end of my rope here. |
|
For me, I had forgotten to include an empty array argument (or a dependency array) in the See the documentation:
|
|
I can't believe I missed that! That was also my problem. Many thanks |
|
Thanks @shennan, that was the issue for me as well. |
|
@Andreeh for me memoizing everything didn't fix the issue. I still keep running into this issue as soon as state changes. Of course, if I set a The moment I change state in the parent, it all breaks down. |
|
Alright.. so in my case I had a custom hook function that I forgot to add |
|
In any None of the advice in this thread resolves it - my columns and data are already properly memoized, my component renders twice if the state of the above two properties equals false, otherwise it will render over 50 times until the referenced maximum depth error occurs... this line of code appears to be where it begins: https://github.com/tannerlinsley/react-table/blob/0bcf87a216eab7b5994c99972da19de6822d5d0e/src/publicUtils.js#L148 My data does not change following the initial render so these two properties are relatively meaningless for me so I can use the above workaround, but it seems that somehow the |
|
You must wrap your |
In my application data is dynamic and changes over time and in some places even column headers do. Is there a solution for my case? |
|
It's okay if your columns and data change over time, as long as their references are not changing every render. useMemo with the proper dependencies and you'll be fine |
It isn't that simple, it seems. What @andrickd mentioned about having to disable library functionality in order for a bug to not occur can't simply be ignored here. Their suggestions allow the many re-renders to not occur but remove needed functionality. |
|
With an empty dependency array the logic for pagination cannot work properly. Is there any workaround to get the row selection working with real dependencies? |
I was having same issue. For me it started when I started to use manualPagination with server side pagination. There is no use of either useMemo or callback, columns defined outside of component. In addition to setting |
|
For anyone who is struggling with similar issue when used |
|
I know this is probably a stale issue, but I resolved a similar problem by separating the table instantiation into two steps. The codesandbox included by the OP defines the table like this: const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow
} = useTable(
{
columns,
data
},
useSortBy
);For me, destructuring directly from the const tableInstance = useTable(
{
columns,
data
},
useSortBy
);
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow
} = tableInstance;Hope this helps. |
|
Thanks, @andrickd for your solution. Save my dark night. |
|
I fixed the issue by wrapping the data in useMemo as well. I thought it was the columns but it turned out that I recompute the data in every render as well. |
Describe the bug (required)
"Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." when building table
Provide an example via Codesandbox! (required)
https://codesandbox.io/s/busy-merkle-58ii6?file=/src/react-table-component.js
Steps To Reproduce (required)
Run code
The text was updated successfully, but these errors were encountered: