redux-toolkit
redux-toolkit copied to clipboard
RTKQ resetApiState is not properly resetting queries when skip=true
- I load the sandbox, the pokemon is fetched.
- I toggle skip (skip is true), the results will vanish.
- I reset the API state.
- Now I toggle skip again (skip is false).
I would expect that (because I made a reset of the API state) that there is no cached data. However, there is.
The documentation of resetApiState states that "Note that hooks also track state in local component state and might not fully be reset by resetApiState.".
Maybe my confusion can be explained with this - so I'm not quite sure if the above is really a bug or intended behavior.
From my experience, don't call resetApiState unless you are definitely sure there are no actively subscribed queries. So most likely you'd want to unmount/unsubscribe all components that use RTK Query hooks before calling resetApiState.
Updated the codesandbox to use the latest @reduxjs/toolkit release.