This commit is contained in:
David Nguyen
2025-02-05 00:57:00 +11:00
parent 540cc5bfc1
commit 1057ae6d2a
105 changed files with 379 additions and 357 deletions

View File

@ -0,0 +1,21 @@
import { useCallback, useEffect } from 'react';
import { useRevalidator } from 'react-router';
export const RefreshOnFocus = () => {
const { revalidate } = useRevalidator();
const onFocus = useCallback(() => {
void revalidate();
}, [revalidate]);
useEffect(() => {
window.addEventListener('focus', onFocus);
return () => {
window.removeEventListener('focus', onFocus);
};
}, [onFocus]);
return null;
};