Sfoglia il codice sorgente

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 7 anni fa
parent
commit
22a1917107
1 ha cambiato i file con 9 aggiunte e 12 eliminazioni
  1. 9
    12
      react/features/app/components/AbstractApp.js

+ 9
- 12
react/features/app/components/AbstractApp.js Vedi File

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
      * @inheritdoc
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
         this._init.then(() => {
69
         this._init.then(() => {
71
             // Deal with URL changes.
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
                     // XXX Refer to the implementation of loadURLObject: in
74
                     // XXX Refer to the implementation of loadURLObject: in
78
                     // ios/sdk/src/JitsiMeetView.m for further information.
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
     }

Loading…
Annulla
Salva