0

I am trying to get my state from inside a saga using the select effect.

I used this answer to start - getState in redux-saga?

Code:

const { select } = ReduxSaga
select()

Using this codepen redux saga setup (line 35).

Error - select is not a function

Much appreciated.

Community
  • 1
  • 1

1 Answers1

1

The select is undefined.

You may need to upgrade your version of react-saga from 0.5.0 to a higher version.

e.g. From https://npmcdn.com/redux-saga@0.5.0/dist/redux-saga.min.js to https://npmcdn.com/redux-saga@0.9.0/dist/redux-saga.min.js

(At least 0.9.0 is ok in my test. 0.12.1 is the latest.)

And import it from ReduxSaga.effects

const { put, call, select } = ReduxSaga.effects;

The revised will be:

enter image description here

Andre Lee
  • 1,180
  • 1
  • 11
  • 13
  • Do'h!! Thanks! It's getting there! `select first argument must be a function`, There must be a way to return the whole state without a selector? –  Nov 13 '16 at 02:08
  • From Docs `If select is called without argument (i.e. yield select()) then the effect is resolved with the entire state (the same result of a getState() call).` –  Nov 13 '16 at 02:12
  • Thanks! This worked... `const getState = state => state` `var state = yield select(getState)` –  Nov 13 '16 at 02:28
  • 1
    Yep, 0.9.0 doesn't allow `selector` can be `null`. 0.12.1 allows it. The Docs you read should be the latest, right? Congrats that you get it worked. – Andre Lee Nov 13 '16 at 02:42