Skip to content

shakogegia/react-shallow-compare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

import { shouldUpdate } from recompose
import { shallowCompare, shallowCompareOnly, shallowCompareExclude } from 'react-shallow-compare'

you can choose 3 methods

compare whole props

  shouldUpdate(shallowCompare),

or white list props

  shouldUpdate(shallowCompareOnly(['prop1', 'prop2'])),

or black list props

  shouldUpdate(shallowCompareExclude(['prop1', 'prop2'])),

you can also you it without recompose

import { shallowCompare } from 'react-shallow-compare'


class MyComponent extends React.Component {
  ...
  
  shouldComponentUpdate(nextProps, nextState) {
    return shallowCompare(this.props, nextProps)
  }
  ...
}

About

Shallow Compare props for react that works for with immutable.js too you can use it with recompose

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors