|
|
@@ -56,18 +56,33 @@ class Root extends Component {
|
|
56
|
56
|
url: this.props.url
|
|
57
|
57
|
};
|
|
58
|
58
|
|
|
59
|
|
- // Handle the URL, if any, with which the app was launched.
|
|
60
|
|
- Linking.getInitialURL()
|
|
61
|
|
- .then(url => this.setState({ url }))
|
|
62
|
|
- .catch(err => {
|
|
63
|
|
- console.error('Failed to get initial URL', err);
|
|
|
59
|
+ // Handle the URL the application was launched with, but props have
|
|
|
60
|
+ // precedence.
|
|
|
61
|
+ if (typeof this.props.url === 'undefined') {
|
|
|
62
|
+ Linking.getInitialURL()
|
|
|
63
|
+ .then(url => {
|
|
|
64
|
+ this.setState({ url });
|
|
|
65
|
+ })
|
|
|
66
|
+ .catch(err => {
|
|
|
67
|
+ console.error('Failed to get initial URL', err);
|
|
64
|
68
|
|
|
65
|
|
- // XXX Start with an empty URL if getting the initial URL fails;
|
|
66
|
|
- // otherwise, nothing will be rendered.
|
|
67
|
|
- if (this.state.url !== null) {
|
|
|
69
|
+ // Start with an empty URL if getting the initial URL fails
|
|
|
70
|
+ // otherwise, nothing will be rendered.
|
|
68
|
71
|
this.setState({ url: null });
|
|
69
|
|
- }
|
|
70
|
|
- });
|
|
|
72
|
+ });
|
|
|
73
|
+ }
|
|
|
74
|
+ }
|
|
|
75
|
+
|
|
|
76
|
+ /**
|
|
|
77
|
+ * Implements React's {@link Component#componentWillReceiveProps()}.
|
|
|
78
|
+ *
|
|
|
79
|
+ * New props can be set from the native side by setting the appProperties
|
|
|
80
|
+ * property (on iOS) or calling setAppProperties (on Android).
|
|
|
81
|
+ *
|
|
|
82
|
+ * @inheritdoc
|
|
|
83
|
+ */
|
|
|
84
|
+ componentWillReceiveProps(nextProps) {
|
|
|
85
|
+ this.setState({ url: nextProps.url || null });
|
|
71
|
86
|
}
|
|
72
|
87
|
|
|
73
|
88
|
/**
|