Why API called twice? #7548
Answered
by
TkDodo
devhyunjae
asked this question in
Q&A
Why API called twice?
#7548
-
demo: https://tz98lg.csb.app/ ![]() I know it will work when i pass as a prop. But my real world code has a deeeeeep children components and I don't want to drill down this as a prop and react-query does the magic to fetch the api only once. Can somebody help me? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
Jun 11, 2024
Replies: 1 comment 3 replies
-
Because the default |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
devhyunjae
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because the default
staleTime
is zero and you conditionally render components. I'm describing this exact scenario here:https://tkdodo.eu/blog/react-query-as-a-state-manager