flushSync React warning occurs on render() for Modal that contains a Checkbox
See original GitHub issue🐛 Bug report
Since upgrading Chakra from 1.1.6 to 1.2.1 (and beyond), some of our existing code now emits a React warning on render. From what I can tell, this is a regression in Chakra relating to @chakra-ui/focus-lock
, or potentially how it interacts with the underlying react-focus-lock
or react-clientside-effects
dependencies.
It looks like when we bumped our Chakra version, the underlying react-focus-lock
and react-clientside-effects
dependency versions have remained the same in our lockfile.
💥 Steps to reproduce
Render a Modal with a Checkbox element inside of it. You’ll hit the following React warning:
Warning: flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.
💻 Link to reproduction
Here’s a minimal reproduction, the flushSync
warning exhibits on initial render:
https://codesandbox.io/s/exciting-keller-j95hk
🧐 Expected behavior
No React warning emitted.
🧭 Possible Solution
Not sure sorry, I haven’t yet dug into these internals. My next step would be looking into what changed in the @chakra-ui/focus-lock
package version that comes with chakra-ui/react
>= 1.2.0.
🌍 System information
Software | Version(s) |
---|---|
Chakra UI | >= 1.2.0 |
Browser | any |
Operating System | any |
📝 Additional information
nil
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:11 (3 by maintainers)
Top GitHub Comments
I just pushed a fix for this. We’ll release an update shortly.
If the issue persists after upgrading, I’ll re-open it.
Thanks for taking a look @segunadebayo ❤️
I can confirm we are hitting this on the latest version of react (17.0.1) and chakra-ui/react (1.3.4), so I think something else might be going on.
Would you be able to reopen this issue? Thanks!