Created
August 3, 2020 23:39
-
-
Save tannerlinsley/e3d18052b7cb51bd249e13d31f46e522 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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