美文网首页前端学习
redux 组合applyMiddleware 和 devToo

redux 组合applyMiddleware 和 devToo

作者: 小盐_814e | 来源:发表于2020-09-08 10:54 被阅读0次
import {createStore,applyMiddleware,compose} from 'redux';
import createSagaMiddleware from 'redux-saga';
const sagaMiddleware = createSagaMiddleware();
const middlewares = [];

let storeEnhancers = compose(
  applyMiddleware(...middlewares,sagaMiddleware),
  (window && window .devToolsExtension) ? window .devToolsExtension() : (f) => f,
);

const store = createStore(rootReducer, initialState={} ,storeEnhancers);

我的测试代码

import {combineReducers,createStore,applyMiddleware,compose} from "redux";
import {User} from "./redux/user.redux";
import thunk from 'redux-thunk';

//用于chrome redux的扩展项
const reduxExtension=window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__();

let reducer=combineReducers({User});
let store=createStore(reducer,compose(applyMiddleware(thunk),reduxExtension));

export default store;

来源:https://www.jb51.net/article/178293.htm

相关文章

网友评论

    本文标题:redux 组合applyMiddleware 和 devToo

    本文链接:https://www.haomeiwen.com/subject/rxedektx.html