# shallow-compare

> Stand alone shallowCompare for use in libraries that support shouldComponentUpdate

Latest version **1.2.2** (published 2017-09-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install shallow-compare
pnpm add shallow-compare
yarn add shallow-compare
bun add shallow-compare
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2017-09-28 |
| First published | 2016-10-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Maintainers | tkh44 |
| Keywords | react-component |

## Links

- npm: https://www.npmjs.com/package/shallow-compare
- Repository: https://github.com/tkh44/shallow-compare
- Homepage: https://github.com/tkh44/shallow-compare#readme
- Issues: https://github.com/tkh44/shallow-compare/issues
- npm.io page: https://npm.io/package/shallow-compare

## Recent versions

- 1.2.2 (latest) — 2017-09-28
- 1.2.1 — 2017-03-20
- 1.2.0 — 2016-10-27

## README

# shallow-compare

[![npm version](https://badge.fury.io/js/shallow-compare.svg)](https://badge.fury.io/js/shallow-compare)

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

---
_Source: https://npm.io/package/shallow-compare · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
