https://github.com/ythecombinator/deeply-checked-effect
React hook for providing an alternative for useEffect that does a deep comparison of passed objects
https://github.com/ythecombinator/deeply-checked-effect
hooks hooks-api-react react useeffect
Last synced: about 2 months ago
JSON representation
React hook for providing an alternative for useEffect that does a deep comparison of passed objects
- Host: GitHub
- URL: https://github.com/ythecombinator/deeply-checked-effect
- Owner: ythecombinator
- License: mit
- Created: 2019-01-02T07:24:26.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-03T21:22:51.000Z (about 7 years ago)
- Last Synced: 2025-03-12T00:31:15.090Z (11 months ago)
- Topics: hooks, hooks-api-react, react, useeffect
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `@rehooks/deeply-checked-effect`
> React hook for handling deep object comparison in React's `useEffect` hook.
> **Note:** This is using the new [React Hooks API Proposal](https://reactjs.org/docs/hooks-intro.html)
> which is subject to change until React 16.7 final.
>
> You'll need to install `react`, `react-dom`, etc at `^16.7.0-alpha.0`
## Install
```sh
yarn add @rehooks/deeply-checked-effect
```
## Usage
### Sample
```jsx
import useEffect from "@rehooks/deeply-checked-effect";
function UseEffect({ state }) {
useEffect(
() => {
console.log("useEffect", state);
},
[state]
);
return
;
}
```
### API
The `useEffect(create, inputs)` hook takes two parameters and has no return. The mentioned parameters are:
#### `create`
A function that contains imperative, possibly effectful code and is directly invoked inside a regular React's `useEffect` hook.
#### `inputs`
The array of values that the effect depends on and that will be deeply compared for changes.