mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: migrate nextjs to rr7
This commit is contained in:
21
apps/remix/app/components/general/refresh-on-focus.tsx
Normal file
21
apps/remix/app/components/general/refresh-on-focus.tsx
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user