-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
ReferenceError: window is not defined #1044
Comments
I just resolved it. actually, for a moment, it seems like it fixes the issue, but as I keep developing my apps, the issue kicks back. |
I've had the same problem.Have you found the solution now |
Same issue came up, it was because I was using react-ace with next.js. By default next.js renders pages server-side, hence the The fix was to dynamically import (see docs here) the module containing the AceEditor: import dynamic from 'next/dynamic'
const DynamicComponentWithNoSSR = dynamic(
() => import('../components/module_with_editor'),
{ ssr: false }
)
function Home() {
return (
<div>
<Header />
<DynamicComponentWithNoSSR />
<p>HOME PAGE is here!</p>
</div>
)
}
export default Home |
This works in development mode. but when I try to build, I still get the error |
UPDATE: I tried the workaround mentioned here |
If you're in a React + MUI + Next.js setup like me, you could also avoid the SSR (server-side rendering) like so: Page:
Component:
based on the example from @syvlabs |
It's work! Thanks! |
Problem
While I was following this tutorial to build a cloned code-pen apps using
npm
instead of yarn, I receivedReferenceError: window is not defined
I looked up some similar issue that was raised in the past, and people suggested to use
brace
, but the latestreact-ace
currently stops supportingbrace
and suggesting us to use Ace-build which I did, but it fails with the same error.node: v12.8.0
npm: 6.14.8
Sample code to reproduce your issue
References
Progress on: #
The text was updated successfully, but these errors were encountered: