Skip to content

v3.1.0

Compare
Choose a tag to compare
@gaearon gaearon released this 28 Jan 18:11
· 2436 commits to master since this release
  • For Browserify users, Redux should now be properly envified without extra configuration (#1301)
  • createStore() now receives an enhancer such as applyMiddleware() as the last optional argument (#1294)

Wait, what?

You don’t have to change anything. However if you use store enhancers such as applyMiddleware() or Redux DevTools you might like that you can now express the same code in a more JavaScript-friendly way:

- const createStoreWithMiddleware = applyMiddleware(
-   thunk,
-   logger
- )(createStore)
- const store = createStoreWithMiddleware(
-   rootReducer,
-   initialState
- )
+ const store = createStore(
+   rootReducer,
+   initialState,
+   applyMiddleware(thunk, logger)
+ )

For multiple store enhancers you can still use compose() but in a similar more straightforward fashion:

- const finalCreateStore = compose(
-   applyMiddleware(thunk, logger),
-   DevTools.instrument()
- )(createStore)
- const store = finalCreateStore(reducer, initialState)
+ const store = createStore(
+   reducer,
+   initialState,
+   compose(
+     applyMiddleware(thunk, logger),
+     DevTools.instrument()
+   )
+ )

The second initialState argument stays optional so you can skip it when specifying the enhancer.

The old way of doing things still works, too.
We’re just adding a nicer way to apply enhancers, that’s all.

Happy reducing!