redux源码分析:enhancer
createStore 第3个参数本质是上对 createStore 方法的增强
redux 的 createStore 第3个参数
- 本质上是 store enhancer
- 常用的是 applyMiddlewares,其实我们还可以自定义其它的 enhanncer
自定义 enhancer
const ourAwesomeEnhancer = createStore => (reducer, initialState, enhancer) => {
const store = createStore(monitoredReducer, initialState, enhancer);
// add enhancer logic
return {
...store
// you can override the some store properties or add new ones
};
};