State Management · Senior · Question 34 of 75
Can RTK Query and createSlice state coexist in one store?
- ✓Correct answer: Yes: the API slice is just another reducer + middleware; slices can react to its actions
- 2No: RTK Query requires a separate store
- 3Only if all slices are converted to RTK Query endpoints
Explanation
Slices can listen to endpoint actions (builder.addMatcher(api.endpoints.login.matchFulfilled, ...)) - e.g. to store a token after login - while server data stays in the RTK Query cache.