Bläddra i källkod

[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.
efficient_tiling
Saúl Ibarra Corretgé 7 år sedan
förälder
incheckning
1d90826098
2 ändrade filer med 2 tillägg och 2 borttagningar
  1. 1
    1
      react/features/app/middleware.js
  2. 1
    1
      react/features/base/config/reducer.js

+ 1
- 1
react/features/app/middleware.js Visa fil

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

+ 1
- 1
react/features/base/config/reducer.js Visa fil

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

Laddar…
Avbryt
Spara