Closed ErikSin closed 2 months ago
My understanding was that React Query has functionality to handle this kind of need pretty elegantly. I was able to achieve the same thing by solely using their query placeholder data functionality. Curious if you think it makes sense to use this in this situation.
export function useProject(projectId?: string) {
const api = useApi();
return useQuery({
queryKey: [PROJECT_KEY, projectId],
queryFn: async () => {
if (!projectId) throw new Error('Active project ID must exist');
return api.getProject(projectId);
},
enabled: !!projectId,
// This is the part I added
placeholderData: previousData => {
return previousData;
},
});
}
Sweet! Yeah that worked. way too many hours went into this for such a simple fix....
closes #489