Replies: 1 comment 3 replies
-
Hi, https://redux-toolkit.js.org/rtk-query/usage/conditional-fetching Inside the component you manage a local skip state which is initially true and give it to the hook in the options. const { data } = useGetGenerationsQuery(id, { So the request will not be made when the component initially renders. After pressing your button set the skip state to false. Then the request will be made. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have hook useGetGenerationsQuery exported from createApi whitch make get request.
getGenerations: build.query({
query: (generationId,) =>
/cars-generations/${generationId}
,}),
In my function component i want call this hook conditional, for exemple when user click button , after this, this hook will be make request for server. How can i get this but not when component is rendering
Beta Was this translation helpful? Give feedback.
All reactions