Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@react-hook/change

jaredLunde10.3kMIT1.0.0TypeScript support: included

A React hook that invokes a callback anytime a value changes

react, react hook, change hook, react change hook, react onchange hook, onchagne hook

readme


useChange()

Bundlephobia Types NPM Version MIT License

npm i @react-hook/change

A React hook that invokes a callback anytime a value changes

Quick Start

`jsx harmony import useChange from '@react-hook/change'

const useChangeLog = (value) => { // Logs the value each time it changes useChange(value, console.log) }


## API

### useChange(value, onChange)

```ts
const useChange = <T extends any>(
  value: T,
  onChange: (current: T, prev: T) => any
): void
Argument Type Required? Description
value T Yes The value to watch for changes to
onChange (current: T, prev: T) => any Yes This callback is invoked any time the value changes

Returns void

LICENSE

MIT