-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RTKQ useQuery hook does not refetch data after resetApiState()
call
#3119
Comments
resetApiState()
call
I have also noticed this issue, and as a workaround I got it to work using |
The First, I added a common tag to each endpoint. I used export const exampleApi = createApi({
// (...other API options here...)
tagTypes: ['Main'],
endpoints: (builder) => ({
getThing: builder.query({
query: (id) => `things/${id}`,
providesTags: ['Main'],
}),
// (...other API endpoints here...)
})
}) Then, I used dispatch(exampleApi.util.invalidateTags(['Main'])) |
Unfortunately we didn't get to this in time (really sorry!) and the reproduction is gone. Could you please add another reproduction? |
Thank you very much for replying, the preview link should be updated now. |
Thanks for the reply. I have already implemented a workaround like this but I didn't expect it to be necessary. I expected the application to work even if the slice is reset and the component to request the data again, since they are necessary for rendering. That's why I opened an issue here. |
After some investigation, I think this is because of our new |
I've just tested, I confirm that #3333 solves this issue. I have also updated again my preview app and seems to work, thank you again! 🤗 |
The issue is likely a bug in RTKQ and should have been fixed by #1735, although it does not seem so.
I provide a minimal example that showcase the issue in isolation and I share the codebase here
Below the steps to riproduce the bug:
Expected results:
Data is correctly re-fetched after the API reset, the useQuery first returns a loading status and then fulfills causing the component to be re-rendered since it is subscribed to the endpoint.
Actual result:
The page gets stuck in a data loading state and useQuery hook does not fulfill blocking the user flow.
The text was updated successfully, but these errors were encountered: