@react-hook/change
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

import useChange from '@react-hook/change'

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

API

useChange(value, onChange)

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

Package Sidebar

Install

npm i @react-hook/change

Weekly Downloads

1,294

Version

1.0.0

License

MIT

Unpacked Size

14.1 kB

Total Files

20

Last publish

Collaborators

  • jaredlunde