瀏覽代碼

[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é 7 年之前
父節點
當前提交
d5e89a60b7
共有 1 個檔案被更改,包括 10 行新增4 行删除
  1. 10
    4
      react/index.native.js

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

60
         // have precedence.
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 => {
64
+                    if (typeof this.state.url === 'undefined') {
65
+                        this.setState({ url });
66
+                    }
67
+                })
64
                 .catch(err => {
68
                 .catch(err => {
65
                     console.error('Failed to get initial URL', err);
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
     }

Loading…
取消
儲存