-
-
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: How to fill endpoint cache on app start? #1366
Comments
The next version of RTK will have hydration functionality, you can already try out the experiment in #1277 but it is at the moment a work in progress. If you use the CodeSandbox build from there, here's some usage info: It works by writing a Alternatively you can also |
I think hydration will solve part of my problems, but not every. I still need a way to manually set data to api slice in some cases. Let's imagine I have my api slice with |
This would be useful, for example when fetching in static props/server side props in Next.js |
@TomasSestak for SSR we have #1277 coming up, including rehydration of data from the server on the client. |
I believe this is covered by the hydration functionality in 1.7. |
In my app i create store based on some initial data, passed to client. If i have data I need to fill an endpoint cache on app start so it do no call endpoint when query run later with same arg.
i tried to call updateQueryData right after configureStore
but it did nothing. i guess it is impossible to update a query that was not initiated.
so i tried to call initiate and then updateQueryData
but
initiate
call produces request that i dont need. updateQueryData still does nothing, i guess because query is in pending state.Is there any way to achieve this behavior? Or did i miss something?
The text was updated successfully, but these errors were encountered: