elgerlambert / redux-localstorage

Store enhancer that syncs (a subset) of your Redux store state to localstorage.
MIT License
1.32k stars 107 forks source link

After defining paths, the state is empty in localStorage #41

Closed woniesong92 closed 8 years ago

woniesong92 commented 8 years ago
  let middleware = applyMiddleware(thunk, routerMiddleware(history))
  if (__DEBUG__) {
    const devTools = window.devToolsExtension
      ? window.devToolsExtension()
      : require('containers/DevTools').default.instrument()
    middleware = compose(middleware, devTools)
  }

  // Add localStorage
  var paths = ["currentUser", "filters", "router"]
  middleware = compose(middleware,
    persistState(paths, null)
  )

  // Create final store and subscribe router in debug env ie. for devtools
  const store = middleware(createStore)(rootReducer, initialState)

As soon as I add paths argument to persistState, it doesn't store anything. Any idea?

elgerlambert commented 8 years ago

Hi @woniesong92,

Which version of redux-localstorage are you using?

I think you might be using v1.0.0-x and that you're looking at the documentation of 0.4.x. If you are using 1.0.0-x, make sure you look here for the correct documentation.

elgerlambert commented 8 years ago

Closing this for now, but definitely let me know if you still need help!