Bladeren bron

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

j8
Lyubo Marinov 8 jaren geleden
bovenliggende
commit
61fd4e4ce4
2 gewijzigde bestanden met toevoegingen van 11 en 7 verwijderingen
  1. 5
    3
      react/features/app/components/AbstractApp.js
  2. 6
    4
      react/index.native.js

+ 5
- 3
react/features/app/components/AbstractApp.js Bestand weergeven

138
             });
138
             });
139
         }
139
         }
140
 
140
 
141
-        // Deal with URL changes
142
-        if (typeof nextProps.url !== 'undefined') {
143
-            this._openURL(nextProps.url || this._getDefaultURL());
141
+        // Deal with URL changes.
142
+        const { url } = nextProps;
143
+
144
+        if (this.props.url !== url) {
145
+            this._openURL(url || this._getDefaultURL());
144
         }
146
         }
145
     }
147
     }
146
 
148
 

+ 6
- 4
react/index.native.js Bestand weergeven

56
             url: this.props.url
56
             url: this.props.url
57
         };
57
         };
58
 
58
 
59
-        // Handle the URL the application was launched with, but props have
60
-        // precedence.
59
+        // Handle the URL, if any, with which the app was launched. But props
60
+        // have precedence.
61
         if (typeof this.props.url === 'undefined') {
61
         if (typeof this.props.url === 'undefined') {
62
             Linking.getInitialURL()
62
             Linking.getInitialURL()
63
                 .then(url => this.setState({ url }))
63
                 .then(url => this.setState({ url }))
79
      *
79
      *
80
      * @inheritdoc
80
      * @inheritdoc
81
      */
81
      */
82
-    componentWillReceiveProps(nextProps) {
83
-        this.setState({ url: nextProps.url || null });
82
+    componentWillReceiveProps({ url }) {
83
+        if (this.props.url !== url) {
84
+            this.setState({ url: url || null });
85
+        }
84
     }
86
     }
85
 
87
 
86
     /**
88
     /**

Laden…
Annuleren
Opslaan