Skip to content

Instantly share code, notes, and snippets.

@JoshBarr
Last active January 20, 2019 23:21
Show Gist options
  • Save JoshBarr/f302ebf7f43ea596ad6a to your computer and use it in GitHub Desktop.
Save JoshBarr/f302ebf7f43ea596ad6a to your computer and use it in GitHub Desktop.
Flickity React integration
@YarivGilad
Copy link

Hi!
Thank you for sharing!
I'm trying to use this integration in an isomorphic app which renders react also on the server and get the following error:

\node_modules\flickity\js\index.js:40
})( window, function factory( Flickity ) {
    ^
ReferenceError: window is not defined

Do you have any idea how to solve this issue?
Cheers
Ajar

@benbonnet
Copy link

benbonnet commented May 12, 2016

@Ajar-Ajar window does not exists on server-side (initially)

@irisSchaffer
Copy link

If you want to get around this, you'll have to require() flickity, where you need it, rather than importing it :)

@cengizdemir
Copy link

Use this;
Helper:
export function onlyClient(callback) {
if (typeof window !== 'undefined') {
callback();
}
}

Using: onlyClient(() => {
....
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment