From d5e89a60b78b534c9cc0ac31be4195336c56ea30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 6 Jul 2017 10:01:35 +0200 Subject: [PATCH] [RN] Fix passing url prop to Root and App components React (pun intended) to prop changes, that is, load the new specified URL. In addition, fix a hidden bug in loading the initial URL from the linking module: we prefer a prop to the URL the app was launched with, in case somehow both are specified. We (the Jitsi Meet app) are not going to run into this corner case, but let's be defensive just in case. --- react/index.native.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/react/index.native.js b/react/index.native.js index 3617bc399f..66f59d5c31 100644 --- a/react/index.native.js +++ b/react/index.native.js @@ -60,13 +60,19 @@ class Root extends Component { // have precedence. if (typeof this.props.url === 'undefined') { Linking.getInitialURL() - .then(url => this.setState({ url })) + .then(url => { + if (typeof this.state.url === 'undefined') { + this.setState({ url }); + } + }) .catch(err => { console.error('Failed to get initial URL', err); - // Start with an empty URL if getting the initial URL fails; - // otherwise, nothing will be rendered. - this.setState({ url: null }); + if (typeof this.state.url === 'undefined') { + // Start with an empty URL if getting the initial URL + // fails; otherwise, nothing will be rendered. + this.setState({ url: null }); + } }); } }