1.0.0 • Published 4 years ago

@react-hook/change v1.0.0

Weekly downloads
1,547
License
MIT
Repository
github
Last release
4 years ago

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