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

Icons break server-side rendering (window is not defined) #4

Open
witoszekdev opened this issue Aug 8, 2019 · 1 comment
Open

Icons break server-side rendering (window is not defined) #4

witoszekdev opened this issue Aug 8, 2019 · 1 comment
Assignees

Comments

@witoszekdev
Copy link

When using Gatsby along with react-eva-icons the server-side rendering is broken when using regular import:

import Icon from "react-eva-icons"

with error: " WebpackError: ReferenceError: window is not defined"

According to the error message the issue occurs in node_modules/eva-icons/eva.js:354:1
in the isOldIE function that is part of the eva-icon dependency. I've checked the source for eva-icons and didn't found any isOldIE function, so I assume that it is added by Webpack?

Anyway... I've fixed the issue with dynamic ES6 import:

let Icon
if (typeof window !== "undefined") {
  import("react-eva-icons").then(module => Icon = module.default);
}

I suppose it might be a good idea to add note about this in the Readme or perhaps find a better solution to this issue?

@dimitrisraptis96 dimitrisraptis96 self-assigned this Aug 8, 2019
@dimitrisraptis96
Copy link
Owner

Thank you, Jonatan for noticing this issue! I'll try to fix it as soon as possible and keep you updated 🍺

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