From 80212943cca7d8fa104cd7c7929ca711d26ec49c Mon Sep 17 00:00:00 2001 From: Sunny Hirai Date: Wed, 22 May 2019 18:57:29 -0700 Subject: [PATCH] Fix Hot Module Reload for plugins (#2825) * Fix HMR for plugins * Use TheReactPlugin in resolveController argument inside method --- packages/slate-react/src/components/editor.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/slate-react/src/components/editor.js b/packages/slate-react/src/components/editor.js index 992fd0233..b4502043b 100644 --- a/packages/slate-react/src/components/editor.js +++ b/packages/slate-react/src/components/editor.js @@ -145,7 +145,15 @@ class Editor extends React.Component { // Re-resolve the controller if needed based on memoized props. const { commands, placeholder, plugins, queries, schema } = this.props - this.resolveController(plugins, schema, commands, queries, placeholder) + + this.resolveController( + plugins, + schema, + commands, + queries, + placeholder, + ReactPlugin + ) // Set the current props on the controller. const { options, readOnly, value: valueFromProps } = this.props @@ -208,7 +216,7 @@ class Editor extends React.Component { */ resolveController = memoizeOne( - (plugins = [], schema, commands, queries, placeholder) => { + (plugins = [], schema, commands, queries, placeholder, TheReactPlugin) => { // If we've resolved a few times already, and it's exactly in line with // the updates, then warn the user that they may be doing something wrong. warning( @@ -217,7 +225,7 @@ class Editor extends React.Component { ) this.tmp.resolves++ - const react = ReactPlugin({ + const react = TheReactPlugin({ ...this.props, editor: this, value: this.props.value || this.state.value,