tree-changes-hook
TypeScript icon, indicating that this package has built-in type declarations

0.11.3 • Public • Published

tree-changes-hook

NPM version build status Quality Gate Status Coverage

React hook that uses tree-changes to compare changes between two datasets.

Setup

npm install tree-changes-hook

Usage

import React from 'react';
import useTreeChanges from 'tree-changes-hook';

function App(props) {
  const { changed } = useTreeChanges(props);

  React.useEffect(() => {
    if (changed('hasData', true)) {
    	sendAnalyticsEvent('load', 'MySuperPage');
  	}
  });

  return <div>...</div>;
}

It's safe to run all the methods with a useEffect without dependencies, but it works with them too.

API

Please refer to tree-changes README for detailed usage.

License

MIT

Package Sidebar

Install

npm i tree-changes-hook

Weekly Downloads

17,315

Version

0.11.3

License

MIT

Unpacked Size

12.9 kB

Total Files

10

Last publish

Collaborators

  • gilbarbara