From 801bcab4dc7e295e9d61f3a6844a9e57ae9671da Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 14 Jul 2016 08:45:59 -0700 Subject: [PATCH] terms: improve write performance --- app/lib/components/terms.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/lib/components/terms.js b/app/lib/components/terms.js index a971c7e2..15844828 100644 --- a/app/lib/components/terms.js +++ b/app/lib/components/terms.js @@ -1,7 +1,6 @@ import React from 'react'; import Term_ from './term'; import Component from '../component'; -import { shouldComponentUpdate } from 'react-addons-pure-render-mixin'; import { last } from '../utils/array'; import { decorate, getTermProps } from '../utils/plugins'; @@ -59,13 +58,20 @@ export default class Terms extends Component { } } - shouldComponentUpdate (nextProps, nextState) { - let nextProps_ = nextProps; - if (this.props.write || nextProps.write) { - // ignore `write` when performing the comparison - nextProps_ = Object.assign({}, nextProps, { write: null }); + shouldComponentUpdate (nextProps) { + for (const i in nextProps) { + if ('write' === i) continue; + if (this.props[i] !== nextProps[i]) { + return true; + } } - return shouldComponentUpdate.call(this, nextProps_); + for (const i in this.props) { + if ('write' === i) continue; + if (this.props[i] !== nextProps[i]) { + return true; + } + } + return false; } onRef (uid, term) {