https://github.com/shakogegia/react-shallow-compare
Shallow Compare props for react that works for with immutable.js too you can use it with recompose
https://github.com/shakogegia/react-shallow-compare
immutablejs react react-native reactjs shallow-equal
Last synced: 3 months ago
JSON representation
Shallow Compare props for react that works for with immutable.js too you can use it with recompose
- Host: GitHub
- URL: https://github.com/shakogegia/react-shallow-compare
- Owner: shakogegia
- License: mit
- Created: 2018-07-23T20:53:14.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-23T21:10:52.000Z (about 8 years ago)
- Last Synced: 2025-06-08T12:38:47.618Z (about 1 year ago)
- Topics: immutablejs, react, react-native, reactjs, shallow-equal
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shallow Compare
Shallow Compare props for react that works for with `immutable.js` too
you can use it with recompose
install
```
npm i react-shallow-compare --save
```
or
```
yarn add react-shallow-compare
```
### Usage
import
```js
import { shouldUpdate } from recompose
import { shallowCompare, shallowCompareOnly, shallowCompareExclude } from 'react-shallow-compare'
```
you can choose 3 methods
compare whole props
```jsx
shouldUpdate(shallowCompare),
```
or white list props
```jsx
shouldUpdate(shallowCompareOnly(['prop1', 'prop2'])),
```
or black list props
```jsx
shouldUpdate(shallowCompareExclude(['prop1', 'prop2'])),
```
you can also you it without `recompose`
```jsx
import { shallowCompare } from 'react-shallow-compare'
class MyComponent extends React.Component {
...
shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this.props, nextProps)
}
...
}
```