UNPKG

@kilpi/react-client

Version:

Kilpi React Client Components · Kilpi is the authorization framework for full-stack TypeScript applications, designed for flexible, powerful, agnostic, intuitive and developer friendly authorization.

19 lines (15 loc) 399 B
import { useEffect, useRef } from "react"; /** * Create an abort signal that aborts on unmount. */ export function useUnmountAbortSignalRef() { const controllerRef = useRef(new AbortController()); const signalRef = useRef(controllerRef.current.signal); // Reset on unmount useEffect(() => { return () => { controllerRef.current.abort(); }; }, []); return signalRef; }