Handle Error Conditions in a Reducer using redux-actions

Andy Van Slaars
InstructorAndy Van Slaars

Share this video with your friends

Send Tweet

In this lesson, we’ll see how we can handle success and error conditions independently using next and throw properties in a reducerMap with handleActions. We’ll add calls to catch for our fetch calls and display error messages when we encounter an error.

Chester Rivas
Chester Rivas
~ 3 years ago

Are you saying that redux-actions knows automatically to use the next and throw keys depending on if the payload is a success payload or an error payload? Or did I miss something?

Andy Van Slaars
Andy Van Slaarsinstructor
~ 3 years ago

Are you saying that redux-actions knows automatically to use the next and throw keys depending on if the payload is a success payload or an error payload? Or did I miss something?

Yup. If your payload is an Error object, it will use the throw property, anything else will be handled by next

Manjunath
Manjunath
~ 3 years ago

This is so frickin cool. So this only works if you use the actionCreator right ?