mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
terms: improve write performance
This commit is contained in:
parent
8caadca66c
commit
ac689c8b8b
1 changed files with 13 additions and 7 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Term_ from './term';
|
import Term_ from './term';
|
||||||
import Component from '../component';
|
import Component from '../component';
|
||||||
import { shouldComponentUpdate } from 'react-addons-pure-render-mixin';
|
|
||||||
import { last } from '../utils/array';
|
import { last } from '../utils/array';
|
||||||
import { decorate, getTermProps } from '../utils/plugins';
|
import { decorate, getTermProps } from '../utils/plugins';
|
||||||
|
|
||||||
|
|
@ -59,13 +58,20 @@ export default class Terms extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate (nextProps, nextState) {
|
shouldComponentUpdate (nextProps) {
|
||||||
let nextProps_ = nextProps;
|
for (const i in nextProps) {
|
||||||
if (this.props.write || nextProps.write) {
|
if ('write' === i) continue;
|
||||||
// ignore `write` when performing the comparison
|
if (this.props[i] !== nextProps[i]) {
|
||||||
nextProps_ = Object.assign({}, nextProps, { write: null });
|
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) {
|
onRef (uid, term) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue