shallow-compare

WebJar for shallow-compare

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

shallow-compare
Last Version

Last Version

1.2.2
Release Date

Release Date

Type

Type

jar
Description

Description

shallow-compare
WebJar for shallow-compare
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/tkh44/shallow-compare

Download shallow-compare

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/shallow-compare/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>shallow-compare</artifactId>
    <version>1.2.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/shallow-compare/
implementation 'org.webjars.npm:shallow-compare:1.2.2'
// https://jarcasting.com/artifacts/org.webjars.npm/shallow-compare/
implementation ("org.webjars.npm:shallow-compare:1.2.2")
'org.webjars.npm:shallow-compare:jar:1.2.2'
<dependency org="org.webjars.npm" name="shallow-compare" rev="1.2.2">
  <artifact name="shallow-compare" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='shallow-compare', version='1.2.2')
)
libraryDependencies += "org.webjars.npm" % "shallow-compare" % "1.2.2"
[org.webjars.npm/shallow-compare "1.2.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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>
    )
  }
}

Versions

Version
1.2.2