[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.
This commit is contained in:
Saúl Ibarra Corretgé 2017-07-19 10:51:07 +02:00 committed by Любомир Маринов
parent 4efbbe14b1
commit 1d90826098
2 changed files with 2 additions and 2 deletions

View File

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

View File

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