Conditional asignment with yield

Viewed 117

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!

1 Answers

You have to do like this:

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