ソースを参照

[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.
master
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
     }

読み込み中…
キャンセル
保存