tj / frontend-boilerplate

webpack-react-redux-babel-autoprefixer-hmr-postcss-css-modules-rucksack-boilerplate (unmaintained, I don't use it anymore)
2.93k stars 268 forks source link

Throws without devTools extension installed #86

Closed OpenGG closed 7 years ago

OpenGG commented 7 years ago

Without redux-devtools-extension, window.devToolsExtension will be undefined, which causes compose() to throw an error:

Uncaught TypeError: Cannot read property 'apply' of undefined   compose.js:33
  v @ compose.js:33
  createStore @ createStore.js:65
  configure @ index.js?bdd4:14
  (anonymous function) @ index.js?2645:11
  (anonymous function) @ bundle.js:136

This issue is introduced by this pr 07e6658e3914ded8eb3249019cacc0e176e97b04 , reverting to 98101d5bcd1b0002ef2b3ec6b942582fd0895477 fixes it.

FYI, compose() src: https://github.com/reactjs/redux/blob/master/src/compose.js#L21

tj commented 7 years ago

ah lame, reverted for now

zalmoxisus commented 7 years ago

@tj, any reason not to use

const enhancer = compose(       
  applyMiddleware(logger),      
  window.devToolsExtension ? window.devToolsExtension() : noop => noop  
)

as provided in the documentation?

I am considering having helper to reduce it (in case we're using default config) like:

const enhancer = compose(       
  applyMiddleware(logger),      
  ___REDUX_DEVTOOLS_EXTENSION___ || noop => noop    
)

and also to have a babel plugin which would strip noop functions.