From bf6d625e8bcf536fc161555cdcf2b27ce0c0fcad Mon Sep 17 00:00:00 2001 From: steven nguyen Date: Thu, 13 May 2021 22:31:39 -0500 Subject: [PATCH 1/2] fix #2680 https://reactjs.org/docs/react-component.html#shouldcomponentupdate `UNSAFE_componentWillReceiveProps`: https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops --- lib/atom/commands.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/atom/commands.js b/lib/atom/commands.js index fdf8544dd0..e4f54634e0 100644 --- a/lib/atom/commands.js +++ b/lib/atom/commands.js @@ -53,9 +53,9 @@ export class Command extends React.Component { this.observeTarget(this.props); } - componentWillReceiveProps(newProps) { - if (['registry', 'target', 'command', 'callback'].some(p => newProps[p] !== this.props[p])) { - this.observeTarget(newProps); + componentDidUpdate(prevProps) { + if (['registry', 'target', 'command', 'callback'].some(p => prevProps[p] !== this.props[p])) { + this.observeTarget(this.props); } } From ed14d2be8d74167e4e657b4f531317175ef004e0 Mon Sep 17 00:00:00 2001 From: steven nguyen Date: Fri, 14 May 2021 10:17:42 -0500 Subject: [PATCH 2/2] copypaste previous commit `_prevProps` is unused, that's why it has an underscore. Maybe atom does something differently? --- lib/views/git-timings-view.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/views/git-timings-view.js b/lib/views/git-timings-view.js index f689917673..ef1228bc73 100644 --- a/lib/views/git-timings-view.js +++ b/lib/views/git-timings-view.js @@ -171,8 +171,8 @@ class Waterfall extends React.Component { this.state = this.getNextState(props); } - componentWillReceiveProps(nextProps) { - this.setState(this.getNextState(nextProps)); + componentDidUpdate(_prevProps) { + this.setState(this.getNextState(this.props)); } getNextState(props) {