README
Var Hooks
Basic
usePrevious(x: T): T | undefined
- returns a value from previous render.useUpdate(): () => void
- like class-based component'sforceUpdate
.useLatestCallback(fn: T): T
- likeuseCallback
, but always calls the latest providedfn
(no stale closure).Additionally, returned function always has a stable identity, unlike the standard
useCallback
/useMemo
, which may return a new function in some cases as stated in their docs.It's safe to omit the function from the
useEffect
oruseCallback
dependency list.useGetter(x: T): () => T
- returns a function with a stable identity that returns an argument provided to it.It's safe to omit the function from the
useEffect
oruseCallback
dependency list.