ref(app): move url change handling to componentDidUpdate
Instead of handling the side effect of navigating to another url from within componentWillReceiveProps, try to match the same logic instead in componentDidUpdate.
This commit is contained in:
parent
ce01b31514
commit
22a1917107
|
@ -56,28 +56,25 @@ export class AbstractApp extends BaseApp<Props, *> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies this mounted React {@code Component} that it will receive new
|
* Implements React Component's componentDidUpdate.
|
||||||
* props. Makes sure that this {@code AbstractApp} has a redux store to use.
|
|
||||||
*
|
*
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
* @param {Object} nextProps - The read-only React {@code Component} props
|
|
||||||
* that this instance will receive.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
*/
|
||||||
componentWillReceiveProps(nextProps: Props) {
|
componentDidUpdate(prevProps: Props) {
|
||||||
const { props } = this;
|
const previousUrl = toURLString(prevProps.url);
|
||||||
|
const currentUrl = toURLString(this.props.url);
|
||||||
|
const previousTimestamp = prevProps.timestamp;
|
||||||
|
const currentTimestamp = this.props.timestamp;
|
||||||
|
|
||||||
this._init.then(() => {
|
this._init.then(() => {
|
||||||
// Deal with URL changes.
|
// Deal with URL changes.
|
||||||
let { url } = nextProps;
|
|
||||||
|
|
||||||
url = toURLString(url);
|
if (previousUrl !== currentUrl
|
||||||
if (toURLString(props.url) !== url
|
|
||||||
|
|
||||||
// XXX Refer to the implementation of loadURLObject: in
|
// XXX Refer to the implementation of loadURLObject: in
|
||||||
// ios/sdk/src/JitsiMeetView.m for further information.
|
// ios/sdk/src/JitsiMeetView.m for further information.
|
||||||
|| props.timestamp !== nextProps.timestamp) {
|
|| previousTimestamp !== currentTimestamp) {
|
||||||
this._openURL(url || this._getDefaultURL());
|
this._openURL(currentUrl || this._getDefaultURL());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue