Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
David-A-RogersHS2 opened this issue Aug 15, 2018 · 3 comments

Comments

@David-A-RogersHS2
Copy link

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()
  ]
}
@David-A-RogersHS2 David-A-RogersHS2 changed the title Code in the beginner tutorial does not match the finished code in sagas Code in the beginner tutorial does not match the finished code in sagas and doesn't work Aug 15, 2018
@Pasi-D
Copy link

Pasi-D commented Sep 14, 2018

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
Copy link

dgobaud commented Sep 24, 2018

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
Copy link

ydax commented Jan 16, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants