React: Handle an Action in the Store

Handle an Action in the Store

Why this code doesn’t work with a Terner function ?

action.type === 'LOGIN' ? {login: true} : state

First of all, when you post, please show all of the code.

Secondly, what is a “Terner function”?

Lastly, remember that a reducer should always return something.

Oh, you mean “ternary operator”. It’s an operator, not a function.

But yes, I was able to solve this challenge with that code, above. Pay attention to the last thing I mentioned.

return action.type === 'LOGIN' ? {login: true} : state


1 Like

Trust me, there is no mistake you can learn as a beginner that hasn’t been made by thousands of others. And on my path, I’ve probably made them all, some more than once. It’s just part of learning.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.