Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/steamerjs/pure-render-deepcompare-decorator


https://github.com/steamerjs/pure-render-deepcompare-decorator

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

## pure-render-deepCompare-decorator

compare props and state automatically

### Install

```
$ npm install pure-render-deepcompare-decorator --save
```

### Usage

If you don't care the data in `shouldComponentUpdate`, you can just use the decorator way. But you have to install `babel-plugin-transform-decorators-legacy` plugin for compilation.

```js
import pureRender from "pure-render-deepcompare-decorator";

@pureRender
class List extends Component {
constructor(props, context) {
super(props, context);
}

render() {

return (


);
}
}

```

If you need to modify logic in `shouldComponentUpdate`, you can use it like this:

```js
import { deepCompare } from "pure-render-deepcompare-decorator";

class List extends Component {
constructor(props, context) {
super(props, context);
}

shouldComponentUpdate(nextProps, nextState) {

// some logic

var shouldUpdate = /* some logic */

return deepCompare(this, nextProps, nextState) && shouldUpdate;

}

render() {

return (


);
}
}

```

### Immutable Version
* [pure-render-immutable-decorator](https://github.com/SteamerTeam/pure-render-immutable-decorator)