Skip to content

overwrite your component's shouldComponentUpdate to compare deeply

License

Notifications You must be signed in to change notification settings

shisama/pure-deep-equal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pure-deep-equal

GitHub license Dependency Status devDependency Status npm

overwrite your react component's shouldComponentUpdate to compare deeply

Why?

React.PureComponent is very useful to make your react application faster. However, since React.PureComponent uses 'shallow comparison', render method is not invoked when values of Object or array in props or state are changed. I think it may make some bugs and I hope to compare props or state deeply. So, I developed this. That's more, I made this to use it as decorator because I hope to apply 'deep comparison' simply to existing codes. I hope that this library will help you. Thanks;)

Install

npm install --save pure-deep-equal

Usage

import React from "react";
import PureDeepEqual from "pure-deep-equal"

@PureDeepEqual
class Test extends React.Component {
  // ...
}

if you use babel but you haven't yet install babel-plugin-transform-decorator-legacy, install it and setup.

  • install
npm install --save-dev babel-plugin-transform-decorator-legacy
  • setup .babelrc
"plugins": ["transform-decorators-legacy"]

License

This project is licensed under the terms of the MIT license

About

overwrite your component's shouldComponentUpdate to compare deeply

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published