From 29809ab024b93de23ff4f0a2a95917ba2cbe7680 Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Fri, 4 Jan 2019 21:08:15 -0800 Subject: [PATCH] ref(app): set url prop to state in componentDidUpdate This is done to kill off the last deprecated lifecycle usage. There is special logic within index.native to get a default meeting url by asynchronously fetching it, if a url is not passed initially. The url is then put onto state and overridable on subsequent prop updates. --- react/index.native.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/react/index.native.js b/react/index.native.js index b3f0bf10a..cb89314bf 100644 --- a/react/index.native.js +++ b/react/index.native.js @@ -103,15 +103,25 @@ class Root extends Component { } /** - * Implements React's {@link Component#componentWillReceiveProps()}. + * Implements React's {@link Component#componentDidUpdate()}. * * New props can be set from the native side by setting the appProperties * property (on iOS) or calling setAppProperties (on Android). * * @inheritdoc */ - componentWillReceiveProps({ url }) { - equals(this.props.url, url) || this.setState({ url: url || null }); + componentDidUpdate(prevProps, prevState) { + // Ignore the special state update triggered on {@code Root} + // instantiation where an undefined url prop is set to a default. + if (typeof prevState.url === 'undefined' + && typeof this.state.url !== 'undefined') { + return; + } + + if (!equals(prevProps.url, this.props.url)) { + // eslint-disable-next-line react/no-did-update-set-state + this.setState({ url: this.props.url || null }); + } } /**