cra-ssr icon indicating copy to clipboard operation
cra-ssr copied to clipboard

Window is not defined error from third party libraries

Open jackpilowsky opened this issue 6 years ago • 3 comments

I have been running into this issue: Misbehaving libraries that are accessing the window object directly. I have been trying workarounds I have found online but CRA keeps throwing errors

jackpilowsky avatar Nov 29 '18 08:11 jackpilowsky

Ok, I found a workaround that works:

const someMisbehavingLibrary = (isServer ? null : require('misbehaving-library').default);

jackpilowsky avatar Nov 29 '18 09:11 jackpilowsky

Maybe this should be added to the ReadMe or tutorial. It took me a lot of time of trial and error to find the solution

jackpilowsky avatar Nov 29 '18 09:11 jackpilowsky

Hey, my apologies for the long wait @jackpilowsky - I'm looking to ensure this is fixed with version 2.0. If you're interested, I could really use your thoughts for what you'd like to see in the upcoming version. Feel free to comment on the issue here with any suggestions. :)

cereallarceny avatar Jun 19 '19 14:06 cereallarceny