浏览代码

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

React (pun intended) to prop changes, that is, load the new specified URL.

In addition, fix a hidden bug in loading the initial URL from the linking
module: we prefer a prop to the URL the app was launched with, in case somehow
both are specified. We (the Jitsi Meet app) are not going to run into this
corner case, but let's be defensive just in case.
j8
Saúl Ibarra Corretgé 8 年前
父节点
当前提交
d5e89a60b7
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10
    4
      react/index.native.js

+ 10
- 4
react/index.native.js 查看文件

@@ -60,13 +60,19 @@ class Root extends Component {
60 60
         // have precedence.
61 61
         if (typeof this.props.url === 'undefined') {
62 62
             Linking.getInitialURL()
63
-                .then(url => this.setState({ url }))
63
+                .then(url => {
64
+                    if (typeof this.state.url === 'undefined') {
65
+                        this.setState({ url });
66
+                    }
67
+                })
64 68
                 .catch(err => {
65 69
                     console.error('Failed to get initial URL', err);
66 70
 
67
-                    // Start with an empty URL if getting the initial URL fails;
68
-                    // otherwise, nothing will be rendered.
69
-                    this.setState({ url: null });
71
+                    if (typeof this.state.url === 'undefined') {
72
+                        // Start with an empty URL if getting the initial URL
73
+                        // fails; otherwise, nothing will be rendered.
74
+                        this.setState({ url: null });
75
+                    }
70 76
                 });
71 77
         }
72 78
     }

正在加载...
取消
保存