[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 // Deal with URL changes.
if (typeof nextProps.url !== 'undefined') { const { url } = nextProps;
this._openURL(nextProps.url || this._getDefaultURL());
if (this.props.url !== url) {
this._openURL(url || this._getDefaultURL());
} }
} }

View File

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