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

TypeError: (0 , _utils.delay) is not a function

Open shenghu opened this issue 6 years ago • 6 comments

I followed the tutorial to add asynchronous calls. However, I got this error in browser console,

 at rootSaga 
 at takeEvery 
 at incrementAsync 
 TypeError: (0 , _utils.delay) is not a function
    at incrementAsync$ (http://9.181.95.220:9966/build.js:31683:35)
    at tryCatch (http://9.181.95.220:9966/build.js:221:40)
    at Generator.invoke [as _invoke] (http://9.181.95.220:9966/build.js:459:22)
    at Generator.prototype.(anonymous function) [as next] (http://9.181.95.220:9966/build.js:273:21)
    at next (http://9.181.95.220:9966/build.js:29398:27)
    at proc (http://9.181.95.220:9966/build.js:29350:3)
    at runForkEffect (http://9.181.95.220:9966/build.js:29696:19)
    at runEffect (http://9.181.95.220:9966/build.js:29476:472)
    at digestEffect (http://9.181.95.220:9966/build.js:29555:5)

I figured out that in sagas.js, it should be import { delay } from 'redux-saga', instead of import { delay } from 'redux-saga/utils'. But from https://github.com/redux-saga/redux-saga/pull/1401, delay is either in redux-saga/utils or redux-saga/effects, what is expected place to import delay?

shenghu avatar Apr 16 '18 06:04 shenghu

Any updates on this?

olekspickle avatar Dec 03 '18 10:12 olekspickle

My fault, it looks like this was added to CHANGELOG in redux-saga repo:

delay became an effect, old delay function (not effect!) can be imported from @redux-saga/delay-p

jfrux avatar Feb 12 '19 14:02 jfrux

Hi I'm getting the same error with delay following this: https://github.com/redux-saga/redux-saga/blob/master/docs/advanced/RacingEffects.md

If I comment out the delay line it doesn't error.

const { data } = yield race({
  data: take(APP_ACTIONS.APP_FETCH_ENTITLEMENTS_SUCCEEDED),
  timeout: delay(5000),
});

Edit: Fixed by using delay from import { delay } from 'redux-saga' instead - seems this is incorrect in multiple places in the docs?

dominictobias avatar Mar 12 '19 15:03 dominictobias

@DominicTobias Yeah the docs are definitely wrong on this one. Thanks for the save.

borrascador avatar Apr 03 '19 23:04 borrascador

If you could pinpoint places where this is referenced wrong in the docs it would be appreciated, keep in mind that docs are about v1 which differs slightly from 0.x

Andarist avatar Apr 04 '19 07:04 Andarist

Using version "^1.0.1", and having the same issue as @DominicTobias . Work by by using delay from import { delay } from 'redux-saga' however does not work from import {delay} from 'redux-saga/effects

nelsonchen5 avatar May 20 '19 19:05 nelsonchen5