From b032cae2e5da8cb287de18cdffafd8ae4e83254f Mon Sep 17 00:00:00 2001 From: Deep Date: Thu, 6 Dec 2018 14:06:31 +0530 Subject: [PATCH 1/4] Remove componentWillReceiveProps usages in examples --- .../tex/js/components/TeXBlock.js | 30 +++++-------------- .../draft-0-9-1/tex/js/components/TeXBlock.js | 26 +++++----------- src/component/base/DraftEditor.react.js | 1 - website/static/lib/Draft.js | 1 - 4 files changed, 14 insertions(+), 44 deletions(-) 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..f4ce68c6f9 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) { + 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..9b74aa37aa 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) { + 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; }; From 420ab37e64a569307857cb3694bea6ffaad5c74d Mon Sep 17 00:00:00 2001 From: Deep Date: Wed, 12 Dec 2018 13:35:31 +0530 Subject: [PATCH 2/4] Add unused prevState to componentDidUpdate --- examples/draft-0-10-0/tex/js/components/TeXBlock.js | 2 +- examples/draft-0-9-1/tex/js/components/TeXBlock.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 f4ce68c6f9..59f29651a4 100644 --- a/examples/draft-0-10-0/tex/js/components/TeXBlock.js +++ b/examples/draft-0-10-0/tex/js/components/TeXBlock.js @@ -30,7 +30,7 @@ class KatexOutput extends React.Component { this._update(); } - componentDidUpdate(prevProps) { + componentDidUpdate(prevProps, prevState) { if (prevProps.content !== this.props.content) { this._update(); } 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 9b74aa37aa..5c11dae688 100644 --- a/examples/draft-0-9-1/tex/js/components/TeXBlock.js +++ b/examples/draft-0-9-1/tex/js/components/TeXBlock.js @@ -35,7 +35,7 @@ class KatexOutput extends React.Component { this._update(); } - componentDidUpdate(prevProps) { + componentDidUpdate(prevProps, prevState) { if (prevProps.content !== this.props.content) { this._update(); } From 10b1ffb93eda1fedb10aa72b202283601f4d84f4 Mon Sep 17 00:00:00 2001 From: Deep Date: Wed, 12 Dec 2018 15:33:33 +0530 Subject: [PATCH 3/4] Updated natives resolution to 1.1.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b1046d511..a940084c69 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "webpack-stream": "^4.0.0" }, "resolutions": { - "gulp/**/natives": "1.1.3" + "gulp/**/natives": "1.1.6" }, "devEngines": { "node": "8.x || 9.x || 10.x", From f2ed75b1e7e9bcd0c538f205de2ad6457c96817e Mon Sep 17 00:00:00 2001 From: Deep Date: Sun, 20 Jan 2019 15:33:20 +0530 Subject: [PATCH 4/4] Revert natives resolution to 1.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a940084c69..3b1046d511 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "webpack-stream": "^4.0.0" }, "resolutions": { - "gulp/**/natives": "1.1.6" + "gulp/**/natives": "1.1.3" }, "devEngines": { "node": "8.x || 9.x || 10.x",