Skip to content
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

Cannot use with NextJS: 'window' is not defined #10

Open
EliteMasterEric opened this issue Jun 3, 2020 · 1 comment
Open

Cannot use with NextJS: 'window' is not defined #10

EliteMasterEric opened this issue Jun 3, 2020 · 1 comment

Comments

@EliteMasterEric
Copy link

This component cannot be used with NextJS.

Expected Behavior: A simple page should build and render.

Actual Behavior: A ReferenceError: window is not defined is thrown.

CodeSandbox for Minimal Example: https://codesandbox.io/s/nextjs-banner-test-vr6pt?file=/pages/index.js

Notes: I could not locate any code in the repository which uses window directly. It may be used by some module that this component calls.

Version Info:

React v16.13.0
NextJS v9.3.0
material-ui-banner v1.4.3
@arnm
Copy link

arnm commented Jul 28, 2022

Workaround:

...
const [Banner, setBanner] = React.useState<React.FC<any>>()
...
React.useEffect(() => {
    setBanner(require('material-ui-banner').Banner)
}, [])
...
<Banner open />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants