JSPM

@utilityjs/use-on-change

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 417
  • Score
    100M100P100Q65609F
  • License MIT

A React hook that invokes a callback anytime a value changes.

Package Exports

  • @utilityjs/use-on-change
  • @utilityjs/use-on-change/esm/index.js
  • @utilityjs/use-on-change/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@utilityjs/use-on-change) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

useOnChange

A React hook that invokes a callback anytime a value changes.

license npm latest package npm downloads types

npm i @utilityjs/use-on-change | yarn add @utilityjs/use-on-change

Usage

import useOnChange from "@utilityjs/use-on-change";
import * as React from "react";

const MyComponent = (props) => {
  useOnChange(props.isOpen, (currentOpenState) => {
    console.log(`The current open state is: ${currentOpenState}`);
  })

  return ...;
};

API

useOnChange(value, onChange)

declare const useOnChange: <T>(value: T, onChange: (current: T) => void) => void;

value

The value to listen on.

onChange

The callback that is called when value changes.