#464
Hi, I have resolved the issue where pages (/, /projects, /mates) would reload and scroll to the top when the browser tab lost and regained focus.
The global useSWR hook in pages/_app.tsx (used for fetching user details) was re-fetching data on window focus by default. This triggered a re-render of the entire application, causing components to reset.
I disabled this behavior by adding revalidateOnFocus: false to the useSWR options in pages/_app.tsx. This maintains the page state and scroll position when switching tabs.
const { data: profileDetails, isLoading: isDetailsLoading } = useSWR(
getUserDetailsApiUrl,
fetcher,
{
errorRetryCount: 0,
revalidateOnFocus: false, // Add this line
}
);
after fix: https://drive.google.com/file/d/15woO0827VgC061wnJj3YEW9F1RWq9I8t/view?usp=drivesdk
#464
Hi, I have resolved the issue where pages (/, /projects, /mates) would reload and scroll to the top when the browser tab lost and regained focus.
The global useSWR hook in pages/_app.tsx (used for fetching user details) was re-fetching data on window focus by default. This triggered a re-render of the entire application, causing components to reset.
I disabled this behavior by adding revalidateOnFocus: false to the useSWR options in pages/_app.tsx. This maintains the page state and scroll position when switching tabs.
const { data: profileDetails, isLoading: isDetailsLoading } = useSWR(
getUserDetailsApiUrl,
fetcher,
{
errorRetryCount: 0,
revalidateOnFocus: false, // Add this line
}
);
after fix: https://drive.google.com/file/d/15woO0827VgC061wnJj3YEW9F1RWq9I8t/view?usp=drivesdk