Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

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

Saúl Ibarra Corretgécc9249ba1a94
diff --git a/react/features/app/components/AbstractApp.js b/react/features/app/components/AbstractApp.js
index 0701bfcef2..65ecb251a4 100644
--- a/react/features/app/components/AbstractApp.js
+++ b/react/features/app/components/AbstractApp.js
@@ -137,6 +137,11 @@ export class AbstractApp extends Component {
store: this._maybeCreateStore(nextProps)
});
}
+
+ // Deal with URL changes
+ if (typeof nextProps.url !== 'undefined') {
+ this._openURL(nextProps.url || this._getDefaultURL());
+ }
}
/**
diff --git a/react/index.native.js b/react/index.native.js
index 5100227d27..eb88e081d1 100644
--- a/react/index.native.js
+++ b/react/index.native.js
@@ -56,18 +56,33 @@ class Root extends Component {
url: this.props.url
};
- // Handle the URL, if any, with which the app was launched.
- Linking.getInitialURL()
- .then(url => this.setState({ url }))
- .catch(err => {
- console.error('Failed to get initial URL', err);
+ // Handle the URL the application was launched with, but props have
+ // precedence.
+ if (typeof this.props.url === 'undefined') {
+ Linking.getInitialURL()
+ .then(url => {
+ this.setState({ url });
+ })
+ .catch(err => {
+ console.error('Failed to get initial URL', err);
- // XXX Start with an empty URL if getting the initial URL fails;
- // otherwise, nothing will be rendered.
- if (this.state.url !== null) {
+ // Start with an empty URL if getting the initial URL fails
+ // otherwise, nothing will be rendered.
this.setState({ url: null });
- }
- });
+ });
+ }
+ }
+
+ /**
+ * Implements React's {@link Component#componentWillReceiveProps()}.
+ *
+ * New props can be set from the native side by setting the appProperties
+ * property (on iOS) or calling setAppProperties (on Android).
+ *
+ * @inheritdoc
+ */
+ componentWillReceiveProps(nextProps) {
+ this.setState({ url: nextProps.url || null });
}
/**