[TimezonePicker] Warning: Cannot update during an existing state transition
See original GitHub issueWhen opening, clicking and generally using the TimezonePicker the console throws the following error:
Warning: Cannot update during an existing state transition (such as within
render). Render methods should be a pure function of props and state.
I thought it may be something with my local setup (just testing out BaseWeb and TimezonePicker was my first component to test), but following the link from the docs page to CodeSandbox, the error is also reported in the console there: https://codesandbox.io/s/pulvl?module=/example.js
Expected Behavior
No errors in console.
Your Environment
Tech | Version |
---|---|
Base UI | v7.8.0 |
React | 16.8.6 |
browser | Chrome 75.x |
- I have searched the issues of this repository and believe that this is not a duplicate.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Warning: setState(...): Cannot update during an existing state ...
It looks like the app gets in a loop: Warning: setState(...): Cannot update during an existing state transition (such as within ...
Read more >Diagnosing React's "Cannot update during an existing state ...
What is the “Cannot update during an existing state transition” error in React? When you try to update state inside of the render()...
Read more >setState(...): Cannot update during an existing state transition ...
I have a react component which is basically a form that submits a company's data. Everything is okay till I fill the form...
Read more >setState(…): Cannot update during an existing state transition ...
It looks like the app gets in a loop: Warning: setState(...): Cannot update during an existing state transition (such as within `render` or ......
Read more >react_bad_update_state - Rule | DeepScan
This rule was introduced in DeepScan 1.3.0-beta. See. React Warning: setState(…): Cannot update during an existing state transition (such as ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m not sure this a good first issue anymore 😃
I have a tight deadline, but do plan to collaborate in the future with fixes such as for example the missing error / positive state on some components. Those seem like good first issues, while this one seems to be potentially very breaking for several components that depend on it.
I’ve narrowed down the source of the issue here 👍 #1291 introduced a conditional inside
getRequiredItemProps
ofsrc/menu/stateful-container#L210
that triggers asetState
.This
setState
is updating thearia-activedescendant
on theMenu
being used in anySelect
component. This includesTimezonePicker
that usesSelect
.This happens on first render as I believe every option is mapped invoking
getRequiredItemProps
atsrc/menu/menu#L64
.A solution could potentially be made inside
Menu
by explicitly updating an element ref attribute instead of triggering an entire state change. This would require an element ref for theList
component and potentially a ref for the currentactivedescendant
.