use-deep
v1.2.0
Published
use-deep is a React hook library that provides deep-equality versions of useEffect, useCallback, and useMemo, ensuring more accurate dependency comparison for complex data structures.
Downloads
28
Readme
use-deep
use-deep
is a React hook library that provides deep-equality versions of useEffect
, useCallback
, and useMemo
, ensuring accurate dependency comparison for complex or deeply nested data structures.
Features
- Deep comparison of dependencies to prevent unnecessary re-renders and side-effects.
- Provides alternatives to React's
useEffect
,useCallback
, anduseMemo
with deep equality checks.
Installation
Install the package via npm or yarn:
yarn add use-deep
API & Usage
import { useDeepEffect, useDeepCallback, useDeepMemo } from 'use-deep';
function Component() {
useDeepEffect(() => {
// ...
}, deps);
const memoizedValue = useDeepMemo(() => {
// ...
}, deps)
const callback = useDeepCallback((a: number, b: number) => {
return a + b;
}, deps)
}