deno.land / x / ultra@v2.3.8 / hooks / use-mounted-state.js

use-mounted-state.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { useCallback, useEffect, useRef } from "react";
/** * @returns {() => boolean} */export default function useMountedState() { const mountedRef = useRef(false); const get = useCallback(() => mountedRef.current, []);
useEffect(() => { mountedRef.current = true;
return () => { mountedRef.current = false; }; }, []);
return get;}
ultra

Version Info

Tagged at
8 months ago