Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tannerlinsley/e3d18052b7cb51bd249e13d31f46e522 to your computer and use it in GitHub Desktop.
Save tannerlinsley/e3d18052b7cb51bd249e13d31f46e522 to your computer and use it in GitHub Desktop.
// Scenario 1
const { data } = useQuery(
'jointKey1and2',
() => Promise.all([fetch1(), fetch2()]),
{
refetchInterval: 1000,
}
)
useQuery(['key3', data.id], fetch3, {
enabled: data?.id,
})
// Scenario 2
const { data } = useQuery(
'jointKey1and2',
() => Promise.all([fetch1(), fetch2()]),
{
refetchInterval: 1000,
onSuccess: () => {
queryCache.invalidateQuery('key3')
},
}
)
useQuery('key3', fetch3, {
enabled: data?.id,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment