You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

shallow-compare

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shallow-compare

Stand alone shallowCompare for use in libraries that support shouldComponentUpdate

1.2.2
latest
Source
npmnpm
Version published
Weekly downloads
296K
10.28%
Maintainers
1
Weekly downloads
 
Created
Source

shallow-compare

npm version

Stand alone shallowCompare for use in libraries that support shouldComponentUpdate

API

shallowCompare(instance, nextProps, nextState)

  • instance (component instance) - the component's instance (this)
  • nextProps (object) - the next props
  • nextState (object) - the next state

Example

class Foo extends Component {
  constructor (props) {
    super(props);
    this.state = { color: 'blue' }
  }

  shouldComponentUpdate (nextProps, nextState) {
    return shallowCompare(this, nextProps, nextState)
  }

  render () {
    return (
      <div>{this.state.color}</div>
    )
  }
}

Keywords

react-component

FAQs

Package last updated on 28 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts