graingert / WOW

Reveal CSS animation as you scroll down a page
https://wowjs.uk
Other
1.58k stars 1.56k forks source link

SSR support? #20

Closed kahurangitama closed 5 years ago

kahurangitama commented 5 years ago

Hi! I'm trying to use wowjs in React app and everything was fine, until I moved the project to SSR. Since on server we have no window object it says:

/client/node_modules/wowjs/dist/wow.js:336
      if ('requestAnimationFrame' in window) {
                                     ^

ReferenceError: window is not defined

Is there any possibility to review the lib and include SSR support?

graingert commented 5 years ago

wow is deprecated in favour of aos, and when building a react application you should always look for modern libraries, and avoid legacy ones that predate React eg: https://github.com/researchgate/react-intersection-observer/blob/master/README.md

graingert commented 5 years ago

You can also conditionally import wow, based on process.browser