Browse Source

[RN] Use a more resilient way for testing if we are on React Native

navigator.product is read-only, so we don't run into the risk of it being
changed.
master
Saúl Ibarra Corretgé 7 years ago
parent
commit
1d90826098
2 changed files with 2 additions and 2 deletions
  1. 1
    1
      react/features/app/middleware.js
  2. 1
    1
      react/features/base/config/reducer.js

+ 1
- 1
react/features/app/middleware.js View File

@@ -83,7 +83,7 @@ function _navigate({ dispatch, getState }) {
83 83
     // abstraction. Because of the first point, I'm leaving the second point
84 84
     // unresolved to attract attention to the fact that the following needs more
85 85
     // thinking.
86
-    if (navigator.userAgent.match(/react[ \s-]*native/i)) {
86
+    if (navigator.product === 'ReactNative') {
87 87
         // Create/destroy the local tracks as needed: create them the first time
88 88
         // we are going to render an actual route (be that the WelcomePage or
89 89
         // the Conference).

+ 1
- 1
react/features/base/config/reducer.js View File

@@ -73,7 +73,7 @@ ReducerRegistry.register(
73 73
  */
74 74
 function _getInitialState() {
75 75
     return (
76
-        navigator.userAgent.match(/react[ \s-]*native/i)
76
+        navigator.product === 'ReactNative'
77 77
             ? INITIAL_RN_STATE
78 78
             : INITIAL_NON_RN_STATE);
79 79
 }

Loading…
Cancel
Save