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; });- ✓Correct answer: Use
builder.addMatcherwith a matcher likeisPending(...) - 2Add a separate
addCasefor every thunk - there's no alternative - 3Use
extraReducersas an array
Explanation
Matchers run for any action that satisfies them. RTK ships isPending, isFulfilled, isRejected and isAnyOf helpers.