Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigator on React Native is undefined #3137

Closed
gastonmorixe opened this issue Mar 10, 2018 · 5 comments · Fixed by #3164
Closed

Navigator on React Native is undefined #3137

gastonmorixe opened this issue Mar 10, 2018 · 5 comments · Fixed by #3164

Comments

@gastonmorixe
Copy link

          if (navigator && navigator.userAgent.indexOf('Chrome') > -1) {
            // tslint:disable-next-line
            console.debug(
              'Download the Apollo DevTools ' +
                'for a better development experience: ' +
                'https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm',
            );
          }
@gastonmorixe gastonmorixe changed the title Navigator on React Native is not found Navigator on React Native is undefined Mar 10, 2018
@n1ru4l
Copy link
Contributor

n1ru4l commented Mar 10, 2018

Something like this could be sufficient: https://stackoverflow.com/a/13644360/4202031

/label good first issue

@ghost ghost added the good first issue label Mar 10, 2018
@gastonmorixe
Copy link
Author

@n1ru4l thanks but I don't understand. I am saying that the lib is throwing this error.

@n1ru4l
Copy link
Contributor

n1ru4l commented Mar 11, 2018

@gastonmorixe This is an issue in

if (navigator.userAgent.indexOf('Chrome') > -1) {
that has to be fixed.

The link I shared provides an example that could be used.

Changing navigator to window.navigator should be enough.

radko93 added a commit to radko93/apollo-client that referenced this issue Mar 16, 2018
peggyrayzis pushed a commit that referenced this issue Mar 22, 2018
@gastonmorixe
Copy link
Author

gastonmorixe commented Mar 25, 2018

Not solved guys.

Should be

if (window && 
window.navigator && 
window.navigator.userAgent && 
window.navigator.userAgent.indexOf('Chrome') > -1)```

@benjamn
Copy link
Member

benjamn commented Oct 5, 2018

Right, React Native has window.navigator.product === "ReactNative", but apparently does not have a userAgent property.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants