reactjs - ReferenceError: window is not defined (devToolsExtension) -


so, i'm attempting make 'react developer tools' chrome extension aware of app, receiving above mentioned error. can advice best way address issue?

import configuremiddleware './configuremiddleware';  import configurereducer './configurereducer';  import configurestorage './configurestorage';  import { applymiddleware, createstore, compose } 'redux';  import { persiststore, autorehydrate } 'redux-persist';    type options = {    initialstate: object,    platformdeps?: object,    platformmiddleware?: array<function>,  };    const configurestore = (options: options) => {    const {      initialstate,      platformdeps = {},      platformmiddleware = [],    } = options;      const reducer = configurereducer(initialstate);      const middleware = configuremiddleware(      initialstate,      platformdeps,      platformmiddleware,    );      const enhancers = compose(      window.devtoolsextension ? window.devtoolsextension() : f => f    );      const store = createstore(      reducer,      initialstate,      compose(        applymiddleware(...middleware),        autorehydrate(),      ),      enhancers,    );

are doing server-side rendering chance?

one quick fix can think of silence error when window not available add check this:

const enhancers = compose(  (typeof window !== 'undefined' && window.devtoolsextension) ? window.devtoolsextension() : f => f ); 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -