Jortega
Jortega

Reputation: 61

Conditional asignment with yield

I'm working in a react, redux, sagas project and in the saga file I have all the generators. Inside one generator I want to asign a variable like this:

const test = obj?.test || yield call("other generator")

But I can't do this because i got the following error:

"Parsing error: Can not use 'yield' as identifier inside a generator". 

I don't understand why. Can someone tell me why it's not working?

Thanks!

Upvotes: 2

Views: 511

Answers (1)

Mahdi Ta'ala
Mahdi Ta'ala

Reputation: 380

You have to do like this:

    const test = yield obj?.test || call("other generator")

Upvotes: 3

Related Questions