Packages

redux

5.0.1 · 23 Dec 2023MIT62.6M / weekRepositoryHomepagenpmAtom feed

Your version

3.1.0

28 Jan 2016Where it was published

3.7.2 is the newest release of 3.x.

npm marks 3.1.0 as deprecated: Versions before 3.1.3 are known to crash on IE in some cases. Please update to 3.1.3 or newer.

In short

2 changed

Release note

  • For Browserify users, Redux should now be properly envified without extra configuration

  • createStore() now receives an enhancer such as applyMiddleware() as the last optional argument

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!