You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that when <StrictMode> is removed in the index.js file the error does not occur.
When the version of @react-aria/focus is changed to 3.7.0 the error also does not occur.
🌍 Your Environment
Software
Version(s)
@react-aria/focus
3.8.0
Browser
Chrome 104.0.5112.101
Operating System
MacOS 12.5.1
The text was updated successfully, but these errors were encountered:
RubenStoesser
changed the title
FocusScope breaks in React.StrictMode
FocusScope broken in React.StrictMode
Aug 29, 2022
RubenStoesser
changed the title
FocusScope broken in React.StrictMode
FocusScope broken in React 18 StrictMode
Aug 29, 2022
🐛 Bug Report
The last update (
v3.8.0
) to@react-aria/focus
has introduced code that breaksFocusScope
when running in React 18StrictMode
.Rendering a
<FocusScope
throws this error:The issue does not occur when StrictMode is not enabled or
v3.7.0
of@react-aria/focus
is used.🤔 Expected Behavior
FocusScope should not throw an error when rendering.
😯 Current Behavior
Whenever a FocusScope is rendered in StrictMode an error is thrown:
The error seems to be thrown when trying to assign
focusScopeTree.getTreeNode(scopeRef).nodeToRestore
in thisuseLayoutEffect
:react-spectrum/packages/@react-aria/focus/src/FocusScope.tsx
Line 456 in 2411012
💻 Code Sample
Example Code Sandbox using the example code from react-aria docs:
https://codesandbox.io/s/react-spectrum-template-forked-88lk5n?file=/src/App.js
To reproduce just click on the "open" button.
Note that when
<StrictMode>
is removed in theindex.js
file the error does not occur.When the version of
@react-aria/focus
is changed to3.7.0
the error also does not occur.🌍 Your Environment
The text was updated successfully, but these errors were encountered: