redux
5.0.1 · 23 Dec 2023MIT62.6M / weekRepositoryHomepagenpmAtom feed
3.7.2 is the newest release of 3.x.
In short
2 changed
Release note
For Browserify users, Redux should now be properly envified without extra configuration
createStore()now receives an enhancer such asapplyMiddleware()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!