You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've functionality of showing skeleton loader on load. And loading ring on top when fetch newest data. I've used isPending state for skeleton loader and isRefetching state to show newest data fetching loading ring.
I'm using next js.
But after I did optimisation done for SSR by adding prefetchInfiniteQuery in page.tsx I faced below issue.
Actual behaviour:
So when I refresh the page I got isPending to true. Then immediately after isPending false, isRefetching gets true. So I'm seeing both loader one by one on initial page load. So may be it's because of the immediate refetch is done
Expected behaviour:
On Initial load only skeleton loading should show. And when I fetch new data on click of button should show loading ring on top.
Below is my code
ReactQueryProvider
export function ReactQueryProvider({ children }: { children: ReactNode }) {
const queryClient = new QueryClient({
defaultOptions: {
queries: {
// With SSR, we usually want to set some default staleTime
// above 0 to avoid refetching immediately on the client
staleTime: 60 * 1000,
},
},
});
return (
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've functionality of showing skeleton loader on load. And loading ring on top when fetch newest data. I've used isPending state for skeleton loader and isRefetching state to show newest data fetching loading ring.
I'm using next js.
But after I did optimisation done for SSR by adding prefetchInfiniteQuery in page.tsx I faced below issue.
Actual behaviour:
So when I refresh the page I got isPending to true. Then immediately after isPending false, isRefetching gets true. So I'm seeing both loader one by one on initial page load. So may be it's because of the immediate refetch is done
Expected behaviour:
On Initial load only skeleton loading should show. And when I fetch new data on click of button should show loading ring on top.
Below is my code
ReactQueryProvider
Page.tsx
Component.tsx
How to avoid initial refetch on load ? Anyone have an solution please help. Thanks in advanced.
Beta Was this translation helpful? Give feedback.
All reactions