浏览代码

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

j8
Lyubo Marinov 8 年前
父节点
当前提交
61fd4e4ce4
共有 2 个文件被更改,包括 11 次插入7 次删除
  1. 5
    3
      react/features/app/components/AbstractApp.js
  2. 6
    4
      react/index.native.js

+ 5
- 3
react/features/app/components/AbstractApp.js 查看文件

@@ -138,9 +138,11 @@ export class AbstractApp extends Component {
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 查看文件

@@ -56,8 +56,8 @@ class Root extends Component {
56 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 61
         if (typeof this.props.url === 'undefined') {
62 62
             Linking.getInitialURL()
63 63
                 .then(url => this.setState({ url }))
@@ -79,8 +79,10 @@ class Root extends Component {
79 79
      *
80 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
     /**

正在加载...
取消
保存