tree-changes-hook

v0.0.1
React hook for [tree-changes](https://github.com/gilbarbara/tree-changes).

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

Metadata

  • MIT
  • Whatever
  • Gil Barbara
  • released 2/28/2021

Downloads

Maintainers