UNPKG

use-hook-kits

Version:

![npm](https://img.shields.io/npm/dt/use-hook-kits.svg) ![npm](https://img.shields.io/npm/v/use-hook-kits.svg) ![NpmLicense](https://img.shields.io/npm/l/use-hook-kits.svg)

23 lines (17 loc) 485 B
import React from "react"; import {isEqual} from "lodash"; export function checkDeps(deps, name) { const reactHookName = `React.${name.replace(/Deep/, "")}`; if (!deps || deps.length === 0) { throw new Error( `${name} should not be used with no dependencies. Use ${reactHookName} instead.` ); } } export function useDeepMemoize(value) { const ref = React.useRef([]); if (!isEqual(value, ref.current)) { ref.current = value; } return ref.current; }