1.0.0 • Published 3 years ago

@dhmk/hooks v1.0.0

Weekly downloads
5
License
MIT
Repository
-
Last release
3 years ago

Var Hooks

Basic

  • usePrevious(x: T): T | undefined - returns a value from previous render.

  • useUpdate(): () => void - like class-based component's forceUpdate.

  • useLatestCallback(fn: T): T - like useCallback, but always calls the latest provided fn (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 or useCallback 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 or useCallback dependency list.

1.0.0

3 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago