From 1bedf89ddfb71752772ac209462b85c8ad31d5dc Mon Sep 17 00:00:00 2001 From: Cheton Wu Date: Tue, 13 Dec 2016 13:09:53 +0800 Subject: [PATCH] react-addons-shallow-compare --- package.json | 3 ++- src/index.jsx | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c272171..4d549f3 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,8 @@ "d3-scale": "^1.0.4", "d3-selection": "^1.0.3", "d3-shape": "^1.0.4", - "d3-timer": "^1.0.3" + "d3-timer": "^1.0.3", + "react-addons-shallow-compare": "^0.14.0 || ^15.0.0" }, "devDependencies": { "babel-cli": "^6.18.0", diff --git a/src/index.jsx b/src/index.jsx index dfdea88..4906e01 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -1,4 +1,5 @@ import React, { Component, PropTypes } from 'react'; +import shallowCompare from 'react-addons-shallow-compare'; import { timer } from 'd3-timer'; import { arc, area } from 'd3-shape'; import * as ease from 'd3-ease'; @@ -111,6 +112,9 @@ class LiquidFillGauge extends Component { } this.draw(); } + shouldComponentUpdate(nextProps, nextState) { + return shallowCompare(this, nextProps, nextState); + } setRes() { const width = (this.props.width * this.props.innerRadius) / 2; const height = (this.props.height * (this.props.innerRadius - this.props.margin)) / 2;