@bscop/use-did-update
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

use-did-update

GitHub license npm version CircleCI Status Coverage

React hook to handle componentDidUpdate lifecycle event.

The effects run after every completed render - except the initial one - but it's also possible to fire them only when certain values have changed.

Install

npm i @bscop/use-did-update

Usage

import useDidUpdate from "@bscop/use-did-update";

useDidUpdate(
  () => {
    // Executed after each render, but the first one.
    console.log("Yay, it's updated");
  }
);

Api

useDidUpdate(effect, [cleanup], [values]);
  • effect: the side effect.

  • cleanup: clean-up logic to execute in case the component is going to be re-rendered.

  • value: the effect is going to be executed only if also one of these values changed.

Contribute

Read the guidelines.

Run tests

npm test

Coverage

Coverage reports are hosted on codecov.

npm run badge:coverage -- --token=<guid>

Bruno Scopelliti
www.brunoscopelliti.com

Package Sidebar

Install

npm i @bscop/use-did-update

Weekly Downloads

55

Version

1.0.0

License

MIT

Unpacked Size

10.8 kB

Total Files

9

Last publish

Collaborators

  • brunoscopelliti