@bscop/use-did-update
v1.0.0
Published
React hook to handle componentDidUpdate lifecycle event.
Maintainers
Readme
use-did-update
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-updateUsage
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 testCoverage
Coverage reports are hosted on codecov.
npm run badge:coverage -- --token=<guid>Bruno Scopelliti
www.brunoscopelliti.com
