Managing 'window' object in Isomorphic App with ReactJS and Flask Python Managing 'window' object in Isomorphic App with ReactJS and Flask Python reactjs reactjs

Managing 'window' object in Isomorphic App with ReactJS and Flask Python


There is no window global when rendering on the server. You can create a fake window, first checking if the window exists:

if (typeof(window) == 'undefined'){    global.window = new Object();}

Alternatively, you can use jsdom, or a similar library to create a fake DOM.


Just add the following to webpack config:

  // By default, Webpack is set up to target the browser,  // not a Node environment. Try setting target in your config:  target: 'node',