From 8ae84c75535e4c09886d94e166563726fe31bccb Mon Sep 17 00:00:00 2001 From: Jay T Date: Wed, 14 Aug 2019 01:18:01 -0700 Subject: [PATCH 1/2] Refactor lifecycle method componentWillMount to componentDidMount --- src/ReactPlayer.js | 10 +++++----- src/singlePlayer.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ReactPlayer.js b/src/ReactPlayer.js index cddf8cd2..8603ceb9 100644 --- a/src/ReactPlayer.js +++ b/src/ReactPlayer.js @@ -51,13 +51,13 @@ export default class ReactPlayer extends Component { shouldComponentUpdate (nextProps, nextState) { return !isEqual(this.props, nextProps) || !isEqual(this.state, nextState) } - componentWillUpdate (nextProps) { - const { light } = this.props - this.config = getConfig(nextProps, defaultProps) - if (!light && nextProps.light) { + componentDidUpdate(prevProps) { + const { light } = prevProps + this.config = getConfig(this.props, defaultProps) + if (!light && this.props.light) { this.setState({ showPreview: true }) } - if (light && !nextProps.light) { + if (light && !this.props.light) { this.setState({ showPreview: false }) } } diff --git a/src/singlePlayer.js b/src/singlePlayer.js index 7148bdfe..078e15cf 100644 --- a/src/singlePlayer.js +++ b/src/singlePlayer.js @@ -17,8 +17,8 @@ export default function createSinglePlayer (activePlayer) { shouldComponentUpdate (nextProps) { return !isEqual(this.props, nextProps) } - componentWillUpdate (nextProps) { - this.config = getConfig(nextProps, defaultProps) + componentDidUpdate () { + this.config = getConfig(this.props, defaultProps) } getDuration = () => { if (!this.player) return null From 968d02849152d23dd6f187a375043e1d5d2cac3e Mon Sep 17 00:00:00 2001 From: Jay T Date: Wed, 14 Aug 2019 03:23:40 -0700 Subject: [PATCH 2/2] Add space between function name and paren for standardjs lint --- src/ReactPlayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReactPlayer.js b/src/ReactPlayer.js index 8603ceb9..593f7291 100644 --- a/src/ReactPlayer.js +++ b/src/ReactPlayer.js @@ -51,7 +51,7 @@ export default class ReactPlayer extends Component { shouldComponentUpdate (nextProps, nextState) { return !isEqual(this.props, nextProps) || !isEqual(this.state, nextState) } - componentDidUpdate(prevProps) { + componentDidUpdate (prevProps) { const { light } = prevProps this.config = getConfig(this.props, defaultProps) if (!light && this.props.light) {