redux-saga-beginner-tutorial icon indicating copy to clipboard operation
redux-saga-beginner-tutorial copied to clipboard

为什么按照初级教程过后控制台没有打印出helloSaga

Open Chaos-M opened this issue 7 years ago • 5 comments

_20170815110951

Chaos-M avatar Aug 15 '17 03:08 Chaos-M

文档写的时候应该是旧版本,现在升级后使用方法变了。 请参考官方文档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);

Witee avatar Aug 15 '17 13:08 Witee

刚看到4个月之前把package.json 中 redux-saga的版本升了,但没有更新文档.

Witee avatar Aug 15 '17 13:08 Witee

 ̄へ ̄

yunyi1895 avatar Sep 21 '17 05:09 yunyi1895

我也是。。。。。话说中文文档不更新了吗?

ghost avatar Mar 14 '18 14:03 ghost

中文文档滞后,看英文真累,源码看不懂 报个错就无所适从了。。。

ElvisWangTech avatar May 20 '18 08:05 ElvisWangTech