State Management · Middle · Question 52 of 75

How do you handle the pending state of many thunks with one case in a slice?

builder.addMatcher(isPending(fetchUsers, fetchPosts), (state) => { state.loading = true; });

Explanation

Matchers run for any action that satisfies them. RTK ships isPending, isFulfilled, isRejected and isAnyOf helpers.

Further reading

Problem with a question

State Management · Middle · question 52

Test yourself

Take the State Management · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz