redux-saga-beginner-tutorial
redux-saga-beginner-tutorial copied to clipboard
为什么按照初级教程过后控制台没有打印出helloSaga
文档写的时候应该是旧版本,现在升级后使用方法变了。
请参考官方文档https://github.com/redux-saga/redux-saga/tree/master/docs/api#createsagamiddlewareoptions
main.js
import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';
import Counter from './Counter';
import reducer from './reducers';
import { helloSaga } from './saga';
const sagaMiddleware = createSagaMiddleware()
const store = createStore(
reducer,
applyMiddleware(sagaMiddleware)
);
sagaMiddleware.run(helloSaga)
const action = type => store.dispatch({ type });
function render() {
ReactDOM.render(
<Counter
value={store.getState()}
onIncrement={() => action('INCREMENT')}
onDecrement={() => action('DECREMENT')}
onIncrementAsync={() => action('INCREMENT_ASYNC')}
/>,
document.getElementById('root'),
);
}
render();
store.subscribe(render);
刚看到4个月之前把package.json 中 redux-saga的版本升了,但没有更新文档.
 ̄へ ̄
我也是。。。。。话说中文文档不更新了吗?
中文文档滞后,看英文真累,源码看不懂 报个错就无所适从了。。。