A collection of my React Hooks for me.
Provides type definitions for TypeScript.
npm i my-react-hooks
API
useRefMemo
Like useMemo
, but always returns the same ref object whose content is updated with the return value of given function every time one of dependent values is updated.
useShallowMemo
Like useMemo
, but returned value is not updated when a new value is shallow-equal to previous one.
useUpdateSignal
Given a function which compares previous and current dependencies, returns a new integer every time that function returns true.
Use when you need sophisticated control over when useEffect
and likewise are fired.
Note for TypeScript users: Dependencies should have const assertions (as [ obj ] as const
) so that the type of callback is properly inferred.
License
MIT
Contribution
Welcome
TODO
- Write tests