Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

importing imagesLoaded and other modules that required browser environment #84

Closed
opportunato opened this issue Sep 17, 2015 · 2 comments

Comments

@opportunato
Copy link

Hey!

I've been building on top of your app my own app for quite a while — and now I want to add imagesLoaded to it. The problem is that the code is executed two times, the first time on server — where there is no browser environment and window is obviously undefined — so imagesloaded throws an error during import like this "ReferenceError: window is not defined".

How can we an approach it in the isomorphic app? I see how css is included via webpack loader – could be there some way to do the same with browser-only JS?

@geekyme
Copy link

geekyme commented Sep 26, 2015

@opportunato just wrap your imagesLoaded code in a :

if (process.env.BROWSER) {
    ... your code here
}

@opportunato
Copy link
Author

Cool, thanks!

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

No branches or pull requests

2 participants