fix: resolve error flash on page refresh (#2606)

This commit is contained in:
David Nguyen
2026-03-13 12:37:30 +11:00
committed by GitHub
parent e67e19358a
commit 8d97f1dcfa
2 changed files with 18 additions and 27 deletions
@@ -1,26 +0,0 @@
import { useCallback, useEffect } from 'react';
import { useRevalidator } from 'react-router';
/**
* Not really used anymore, this causes random 500s when the user refreshes while this occurs.
*/
export const RefreshOnFocus = () => {
const { revalidate, state } = useRevalidator();
const onFocus = useCallback(() => {
if (state === 'idle') {
void revalidate();
}
}, [revalidate]);
useEffect(() => {
window.addEventListener('focus', onFocus);
return () => {
window.removeEventListener('focus', onFocus);
};
}, [onFocus]);
return null;
};