From 062b4a64436b6fe859e704526b3a569490a7010e Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Sun, 17 Jul 2016 16:21:23 -0700 Subject: [PATCH] fix to not re-resolve plugins on every update, closes #112 --- lib/components/editor.js | 9 +++++++-- lib/components/void.js | 8 ++++++++ lib/plugins/core.js | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/components/editor.js b/lib/components/editor.js index d3c0112d8..9232039fb 100644 --- a/lib/components/editor.js +++ b/lib/components/editor.js @@ -57,8 +57,13 @@ class Editor extends React.Component { */ componentWillReceiveProps = (props) => { - this.setState({ plugins: this.resolvePlugins(props) }) - this.setState({ state: this.resolveState(props.state) }) + if (props.plugins != this.props.plugins) { + this.setState({ plugins: this.resolvePlugins(props) }) + } + + if (props.state != this.props.state) { + this.setState({ state: this.resolveState(props.state) }) + } } /** diff --git a/lib/components/void.js b/lib/components/void.js index 5def92d80..8b958ab75 100644 --- a/lib/components/void.js +++ b/lib/components/void.js @@ -19,6 +19,14 @@ class Void extends React.Component { state: React.PropTypes.object.isRequired }; + shouldComponentUpdate = (props) => { + return ( + props.node != this.props.node || + props.state.selection.hasEdgeIn(props.node) || + this.props.state.selection.hasEdgeIn(this.props.node) + ) + } + render = () => { const { children, node } = this.props const Tag = node.kind == 'block' ? 'div' : 'span' diff --git a/lib/plugins/core.js b/lib/plugins/core.js index fa1bdd75c..7b1d5a5e5 100644 --- a/lib/plugins/core.js +++ b/lib/plugins/core.js @@ -51,7 +51,6 @@ function Plugin(options = {}) { renderPlaceholder = () => { if (!placeholder) return null const { node, state } = this.props - return (