UNPKG

@utilityjs/use-get-latest

Version:

A React hook that stores & updates `ref.current` with the most recent value.

2 lines 205 B
import{useEffect as e,useLayoutEffect as t,useRef as n}from"react";const r=typeof window<`u`?t:e,i=e=>{let t=n(e);return r(()=>{t.current=e}),t};export{i as useGetLatest}; //# sourceMappingURL=index.js.map