question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Menu._isBrowser returning true on iOS and Android

See original GitHub issue

Environment

Android and iOS

Description

I’m trying to use the Menu component, but when I tap the button to show the menu, I get the error:

TypeError: node.querySelector is not a function. (In 'node.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')', 'node.querySelector' is undefined)

Looking at the code in Menu.js, I can see that _focusFirstDOMNode is being called. In fact I tried with a little log statement:

  console.log(`In _focusFirstDOMNode and isBrowser is ${this._isBrowser()}`);

And the output of this is true, i.e. the code thinks it’s in the browser.

I’ve tried this on Android and iOS and get the same result. If I change the definition of _isBrowser to return false, then everything works.

Can you think of any reason while 'document' in global might be true? Any work arounds?

Reproducible Demo

I thought perhaps having a web view in the application (albeit not displayed when I’ve got the menu showing was maybe the cause, but when I built a minimal test app with a WebView, that worked fine.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
j-aldercommented, Sep 23, 2019

Also experiencing this issue. Downgrading to 2.15.2 prevented the runtime error, but there are features we need in 2.16.0.

1reaction
tasncommented, Jul 5, 2019

I’m getting the same, more information: it works fine with 2.15.2 but breaks with 2.16.0. So a very recent regression.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I check if my React-Native app is running in a web ...
@NicholasPfeiffer definitely "web" ; it only returns "ios" if the app runs as actual iOS app. The whole point of React native is...
Read more >
Platform | Ionic Platform to Customize Apps to Fit Any Device
Note that the same app can return true for more than one platform name. For example, an app running from an iPad would...
Read more >
Browser detection using the user agent - HTTP - MDN Web Docs
Serving different Web pages or services to different browsers is usually a bad idea. The Web is meant to be accessible to everyone, ......
Read more >
The Browser Object - WebdriverIO
If you use WebdriverIO in standalone mode the browser object is returned by the remote method. ... isAndroid, Boolean, Indicates an Android session....
Read more >
Shield Your Internet History: How to Clear Your Cache on Any ...
With iOS, you have the option to either tap Edit or Clear Browsing Data. With the latter (which is the only option on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found