smartlook / smartlook-client

Official Smartlook client for easy frontend integration.
https://smartlook.com
MIT License
28 stars 9 forks source link

window is not defined. #14

Closed shpsyte closed 3 years ago

shpsyte commented 4 years ago

I'm trying to use this package, but I getting an error:

Window is not defined.

Our app is NOT server-side rendering and we're using webpack.

(node:71176) UnhandledPromiseRejectionWarning: ReferenceError: window is not defined

I tried to follow the initial steps. What should I do to work in a kind this environment?

Cheers

amertak commented 4 years ago

Hi,

this should not definitely happen when SSR is not used. What is your setup please?

MishaKav commented 3 years ago

I had the same issue, fixed it with adding !!window.smartlook before init.


import smartlookClient from 'smartlook-client';
// ...
useEffect(() => {
  if (smartAppId && !!window.smartlook) {
    smartlookClient.init(smartAppId);
  }
}, []);