I have several components that make use of user details.
Since user details don't change that often, I want to fetch them only once.
One way would be -
const twentyFourHoursInMs = 1000 * 60 * 60 * 24
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
refetchOnmount: false,
refetchOnReconnect: false,
retry: false,
staleTime: twentyFourHoursInMs,
},
},
})
Other way is to fetch data once in base component and use cached data in other components by using queryClient.getQueryData('user')
Which way would be better?