[RN] Fix passing url prop to Root and App components

This commit is contained in:
Lyubo Marinov 2017-07-06 13:27:00 -05:00
parent 9bd6bbfd95
commit 61fd4e4ce4
2 changed files with 11 additions and 7 deletions

View File

@ -138,9 +138,11 @@ export class AbstractApp extends Component {
});
}
// Deal with URL changes
if (typeof nextProps.url !== 'undefined') {
this._openURL(nextProps.url || this._getDefaultURL());
// Deal with URL changes.
const { url } = nextProps;
if (this.props.url !== url) {
this._openURL(url || this._getDefaultURL());
}
}

View File

@ -56,8 +56,8 @@ class Root extends Component {
url: this.props.url
};
// Handle the URL the application was launched with, but props have
// precedence.
// Handle the URL, if any, with which the app was launched. But props
// have precedence.
if (typeof this.props.url === 'undefined') {
Linking.getInitialURL()
.then(url => this.setState({ url }))
@ -79,8 +79,10 @@ class Root extends Component {
*
* @inheritdoc
*/
componentWillReceiveProps(nextProps) {
this.setState({ url: nextProps.url || null });
componentWillReceiveProps({ url }) {
if (this.props.url !== url) {
this.setState({ url: url || null });
}
}
/**