store.js 934 Bytes
import { createHashHistory } from "history";
import { applyMiddleware, compose, createStore } from 'redux';
import { routerMiddleware } from 'connected-react-router';
import 'regenerator-runtime/runtime';// 这个 runtime 必须在 redux-saga 之前引入
import createSagaMiddleware from 'redux-saga';
import createRootReducer from './reducers';
import createSagaRoot, { helloSaga } from './actions';

export const history = createHashHistory();//createBrowserHistory();

const initialState = {};
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const sagaMiddleware = createSagaMiddleware();
const createStoreWithMiddleware = composeEnhancers(
    applyMiddleware(
        routerMiddleware(history),
        sagaMiddleware
    )
);

const store = createStore(
    createRootReducer(history),
    initialState,
    createStoreWithMiddleware
);
sagaMiddleware.run(createSagaRoot);
export default store;