"Cannot update a component while rendering a different component" when filtering with downshift combobox #4634
Describe the bug#
When using a table that has filters built with a custom <Combobox> component implemented with downshift, I see this React warning in the console:
react_devtools_backend.js:4012 Warning: Cannot update a component (`BrokenVersion`) while rendering a different component (`Combobox`). To locate the bad setState() call inside `Combobox`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
If I remove the custom <Combobox> component and use a <datalist> with an <input>, the warning does not appear.
I read through the React issue linked in the React warning, which describes how to expand the stack trace and look for the first line that is not inside React. When I do this, I see that the first line that is not inside React is within node_modules/@tanstack/react-table/src/index.tsx:85, which is a setState() call inside the useReactTable hook.
I tried solutions suggested in later comments in the React issue above, but was unable to prevent the warning.
Your minimal, reproducible example#
https://stackblitz.com/edit/node-twt1uh?file=README.md
Steps to reproduce#
The table labeled as "Broken Version" reproduces the issue. As noted in the text above the Broken Version table, the steps to reproduce the issue are as follows:
- Click on any of the First, Last, or Email filter inputs.
- Click one of the options in the dropdown list to set it as the filter value.
- Open the JavaScript console and notice a React warning.
Expected behavior#
I expect there to be no warnings when using the custom Combobox component as a filter input. Instead, I see a React warning in the JavaScript console.
How often does this bug happen?#
Every time
Screenshots or Videos#
Platform#
- OS: macOS Monterey Version 12.3
- Browser: Google Chrome Version 108.0.5359.124 (Official Build) (arm64)
react-table version#
8.7.4
TypeScript version#
4.9.4
Additional context#
No response
Terms & Code of Conduct#
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
KevinVandy closed this
Sign in to join this conversation.
we think we finally fixed this in the latest v9 beta