diff --git a/examples/draft-0-10-0/tex/js/components/TeXBlock.js b/examples/draft-0-10-0/tex/js/components/TeXBlock.js index 885c445328..59f29651a4 100644 --- a/examples/draft-0-10-0/tex/js/components/TeXBlock.js +++ b/examples/draft-0-10-0/tex/js/components/TeXBlock.js @@ -18,40 +18,24 @@ import katex from 'katex'; import React from 'react'; class KatexOutput extends React.Component { - constructor(props) { - super(props); - this._timer = null; - } - _update() { - if (this._timer) { - clearTimeout(this._timer); - } - - this._timer = setTimeout(() => { - katex.render( - this.props.content, - this.refs.container, - {displayMode: true}, - ); - }, 0); + katex.render( + this.props.content, + this.refs.container, + {displayMode: true}, + ); } componentDidMount() { this._update(); } - componentWillReceiveProps(nextProps) { - if (nextProps.content !== this.props.content) { + componentDidUpdate(prevProps, prevState) { + if (prevProps.content !== this.props.content) { this._update(); } } - componentWillUnmount() { - clearTimeout(this._timer); - this._timer = null; - } - render() { return
; } diff --git a/examples/draft-0-9-1/tex/js/components/TeXBlock.js b/examples/draft-0-9-1/tex/js/components/TeXBlock.js index e619a9c827..5c11dae688 100644 --- a/examples/draft-0-9-1/tex/js/components/TeXBlock.js +++ b/examples/draft-0-9-1/tex/js/components/TeXBlock.js @@ -21,38 +21,26 @@ import {Entity} from 'draft-js'; class KatexOutput extends React.Component { constructor(props) { super(props); - this._timer = null; } _update() { - if (this._timer) { - clearTimeout(this._timer); - } - - this._timer = setTimeout(() => { - katex.render( - this.props.content, - this.container, - {displayMode: true}, - ); - }, 0); + katex.render( + this.props.content, + this.container, + {displayMode: true}, + ); } componentDidMount() { this._update(); } - componentWillReceiveProps(nextProps) { - if (nextProps.content !== this.props.content) { + componentDidUpdate(prevProps, prevState) { + if (prevProps.content !== this.props.content) { this._update(); } } - componentWillUnmount() { - clearTimeout(this._timer); - this._timer = null; - } - render() { return (
{ componentDidUpdate(): void { this._blockSelectEvents = false; - // moving this here, when it was previously set in componentWillUpdate this._latestEditorState = this.props.editorState; this._latestCommittedEditorState = this.props.editorState; } diff --git a/website/static/lib/Draft.js b/website/static/lib/Draft.js index 07927a3f3b..544d71a960 100644 --- a/website/static/lib/Draft.js +++ b/website/static/lib/Draft.js @@ -10084,7 +10084,6 @@ var DraftEditor = function (_React$Component2) { DraftEditor.prototype.componentDidUpdate = function componentDidUpdate() { this._blockSelectEvents = false; - // moving this here, when it was previously set in componentWillUpdate this._latestEditorState = this.props.editorState; this._latestCommittedEditorState = this.props.editorState; };