1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-29 09:59:48 +02:00

fix to not re-resolve plugins on every update, closes #112

This commit is contained in:
Ian Storm Taylor
2016-07-17 16:21:23 -07:00
parent cab2b60987
commit 062b4a6443
3 changed files with 15 additions and 3 deletions

View File

@@ -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) })
}
}
/**

View File

@@ -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'

View File

@@ -51,7 +51,6 @@ function Plugin(options = {}) {
renderPlaceholder = () => {
if (!placeholder) return null
const { node, state } = this.props
return (
<Placeholder
className={placeholderClassName}