cha
@react-hook/change
npm i @react-hook/change
cha

@react-hook/change

↩ Strongly typed, concurrent mode-safe React hooks

by Jared Lunde

1.0.0 (see all)License:MITTypeScript:Built-In
npm i @react-hook/change
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

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
ArgumentTypeRequired?Description
valueTYesThe value to watch for changes to
onChange(current: T, prev: T) => anyYesThis callback is invoked any time the value changes

Returns void

LICENSE

MIT

Downloads/wk

6.2K

GitHub Stars

1.1K

LAST COMMIT

4mos ago

MAINTAINERS

1

CONTRIBUTORS

22

OPEN ISSUES

17

OPEN PRs

48
VersionTagPublished
1.0.0
latest
2yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate