easybase-react icon indicating copy to clipboard operation
easybase-react copied to clipboard

Window undefined error

Open jolivr opened this issue 5 years ago • 1 comments

I am using the razzlejs framework and I started getting a "window undefined" error in the cache.ts file. I was able to get rid of it by changing the following, beginning on line 3 of /src/cache.ts:

I changed this:

     const storage = new Storage({ storageBackend: window.localStorage });

To this:

     const storage = () => {
           if(typeof window !== undefined){
                 return new Storage({storageBackend: window.localStorage});
            }
       }

It's been working perfectly with testing after this change, so I thought I'd pass it along. Thanks!

jolivr avatar Nov 13 '21 22:11 jolivr

Thank you @jolivr. It's great to have a fix for the razzlejs framework.

I'll add that change for the next release. Thanks!

easybase avatar Nov 15 '21 17:11 easybase