UNPKG

@spark-ui/use-mounted-state

Version:

check the component's mount state

2 lines (1 loc) 260 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react");exports.useMountedState=function(){const e=t.useRef(!1),r=t.useCallback(()=>e.current,[]);return t.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),r};