[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.
This commit is contained in:
parent
948d18f954
commit
d5e89a60b7
|
@ -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 });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue