浏览代码

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.
master
Leonard Kim 6 年前
父节点
当前提交
22a1917107
共有 1 个文件被更改,包括 9 次插入12 次删除
  1. 9
    12
      react/features/app/components/AbstractApp.js

+ 9
- 12
react/features/app/components/AbstractApp.js 查看文件

@@ -56,28 +56,25 @@ export class AbstractApp extends BaseApp<Props, *> {
56 56
     }
57 57
 
58 58
     /**
59
-     * Notifies this mounted React {@code Component} that it will receive new
60
-     * props. Makes sure that this {@code AbstractApp} has a redux store to use.
59
+     * Implements React Component's componentDidUpdate.
61 60
      *
62 61
      * @inheritdoc
63
-     * @param {Object} nextProps - The read-only React {@code Component} props
64
-     * that this instance will receive.
65
-     * @returns {void}
66 62
      */
67
-    componentWillReceiveProps(nextProps: Props) {
68
-        const { props } = this;
63
+    componentDidUpdate(prevProps: Props) {
64
+        const previousUrl = toURLString(prevProps.url);
65
+        const currentUrl = toURLString(this.props.url);
66
+        const previousTimestamp = prevProps.timestamp;
67
+        const currentTimestamp = this.props.timestamp;
69 68
 
70 69
         this._init.then(() => {
71 70
             // Deal with URL changes.
72
-            let { url } = nextProps;
73 71
 
74
-            url = toURLString(url);
75
-            if (toURLString(props.url) !== url
72
+            if (previousUrl !== currentUrl
76 73
 
77 74
                     // XXX Refer to the implementation of loadURLObject: in
78 75
                     // ios/sdk/src/JitsiMeetView.m for further information.
79
-                    || props.timestamp !== nextProps.timestamp) {
80
-                this._openURL(url || this._getDefaultURL());
76
+                    || previousTimestamp !== currentTimestamp) {
77
+                this._openURL(currentUrl || this._getDefaultURL());
81 78
             }
82 79
         });
83 80
     }

正在加载...
取消
保存