leoasis / redux-immutable-state-invariant

Redux middleware that detects mutations between and outside redux dispatches. For development use only.
MIT License
937 stars 37 forks source link

getState() is undefined #27

Closed lamogura closed 6 years ago

lamogura commented 7 years ago

Got this error when adding this to my dev middleware.

const middleware = [
  require('redux-immutable-state-invariant').default,
  thunk,
  promise,
]
const store = createStore(
  rootReducer,
  initialState,
  compose(
    applyMiddleware(...middleware),
    DevTools.instrument() // Enable Redux DevTools
  )
)

"redux": "version": "3.6.0"

screen shot 2017-05-12 at 09 27 32

leoasis commented 7 years ago

Remember that what you import from this library is a "middleware factory", which means it's a function you have to call to get the middleware to inject in Redux. So your example should be changed to be like this:

const middleware = [
  require('redux-immutable-state-invariant').default(), // <-- Notice the parens here
  thunk,
  promise,
]
const store = createStore(
  rootReducer,
  initialState,
  compose(
    applyMiddleware(...middleware),
    DevTools.instrument() // Enable Redux DevTools
  )
)

Hope this helps with the issue!

leoasis commented 6 years ago

Closing since it's been a while this has been open without answer. Feel free to reopen if you still have issues!