-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
["react-aria/interactions] "Uncaught Error: document is not defined" when use SSR and window is defined #7926
Comments
I have forked this repo and will soon provide a PR to fix this. |
LisaRyrholm
added a commit
to LisaRyrholm/react-spectrum
that referenced
this issue
Mar 13, 2025
Fix error when window is set but document is undefined when running SSR. Modify test input data to show problem.
LisaRyrholm
added a commit
to LisaRyrholm/react-spectrum
that referenced
this issue
Mar 13, 2025
Fix error when window is set but document is undefined when running SSR. Modify test input data to show problem. Ignore lint error in testfile
LisaRyrholm
added a commit
to LisaRyrholm/react-spectrum
that referenced
this issue
Mar 13, 2025
Fix error when window is set but document is undefined when running SSR. Modify test input data to show problem. Ignore lint error in testfile
5 tasks
This would be great! We've got Using any component from |
LisaRyrholm
added a commit
to LisaRyrholm/react-spectrum
that referenced
this issue
Mar 22, 2025
Fix error when window is set but document is undefined when running SSR.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Provide a general summary of the issue here
When using SSR and Window is define we get an error ("Uncaught Error: document is not defined") as soon as we add an react-aria component in our solution. Found it when added but also other components.
This may also solve part of the issue: #6534 and #6234
🤔 Expected Behavior?
When doing SSR no exception should be thrown when Window is defined.
😯 Current Behavior
When running the SSR our solution gets the "Uncaught Error: document is not defined" exception.
💁 Possible Solution
Make sure to not only check
window === "undefined"
but also checkdocument === "undefined"
🔦 Context
Our solution uses both frontend and SSR and it is important that the SSR works the same as the frontend rendering.
Doing a workaround with useIsSSR and not load react-aria components if SSR is not acceptable.
🖥️ Steps to Reproduce
Adding a
window = {};
on line 23 in your test-utils/src/ssrWorker.js file will make most of your SSR test suit to crash. Showing the problem with most of the component if window is set but not document. test by runningyarn test:ssr
Version
1.7.1
What browsers are you seeing the problem on?
Chrome, Firefox
If other, please specify.
No response
What operating system are you using?
Windows 11
🧢 Your Company/Team
Avensia/Lyko
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: