zapishis-client/apps/web/hooks/telegram/use-client-once.ts
2024-12-11 15:53:38 +03:00

10 lines
234 B
TypeScript

import { useRef } from 'react';
export function useClientOnce(callback: () => void): void {
const canCall = useRef(true);
if (typeof window !== 'undefined' && canCall.current) {
canCall.current = false;
callback();
}
}