redux-saga / redux-saga-beginner-tutorial

Redux/Redux-saga beginner tutorial
MIT License
587 stars 543 forks source link

Code in the beginner tutorial does not match the finished code in sagas and doesn't work #52

Open David-A-RogersHS2 opened 6 years ago

David-A-RogersHS2 commented 6 years ago

The code in the tutorial does not execute properly. Pressing the async increment button has no effect.

The problem is that the tutorial specifies adding this code:

// notice how we now only export the rootSaga
// single entry point to start all Sagas at once
export default function* rootSaga() {
  yield all([
    helloSaga(),
    watchIncrementAsync()
  ])
}

The sagas branch has the correct code:

// notice how we now only export the rootSaga
// single entry point to start all Sagas at once
export default function* rootSaga() {
  yield [
    helloSaga(),
    watchIncrementAsync()
  ]
}
Pasi-D commented 6 years ago

npm test doesn't run with the given sagas.js in tutorial. It should be changed with export functions.

import { delay } from 'redux-saga'
import { call, put, takeEvery } from 'redux-saga/effects'

export function* helloSaga() {
  console.log('Hello Saga!')
}

export function* incrementAsync() {
  yield call(delay, 1000)
  yield put({type: 'INCREMENT'})
}

export function* watchIncrementAsync() {
  yield takeEvery('INCREMENT_ASYNC', incrementAsync)
}

Again its in the sagas branch.

dgobaud commented 6 years ago

i missed it initially too but on https://redux-saga.js.org/docs/introduction/BeginnerTutorial.html the code right after "Well, redux-saga provides a way to make the above statement possible. Instead of calling delay(1000) directly inside incrementAsync, we'll call it indirectly:" that changes the delay invocation to using call also adds export to incrementAsync.

ydax commented 4 years ago

The code in the tutorial does not execute properly. Pressing the async increment button has no effect.

The problem is that the tutorial specifies adding this code:

// notice how we now only export the rootSaga
// single entry point to start all Sagas at once
export default function* rootSaga() {
  yield all([
    helloSaga(),
    watchIncrementAsync()
  ])
}

The sagas branch has the correct code:

// notice how we now only export the rootSaga
// single entry point to start all Sagas at once
export default function* rootSaga() {
  yield [
    helloSaga(),
    watchIncrementAsync()
  ]
}

Also, I notice that in the Counter.js file, the sagas branch has us adding onIncrementAsync to Counter.propTypes [Line 28 of Counter.js in the sagas branch]. This needs to be added to the tutorial. Students are never instructed to do this.