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

Make it works on React Native #460

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/browser.js
Expand Up @@ -40,7 +40,7 @@ function useColors() {
// NB: In an Electron preload script, document will be defined but not fully
// initialized. Since we know we're in Chrome, we'll just detect this case
// explicitly
if (window && window.process && window.process.type === 'renderer') {
if (window && window.process && window.process.type === 'renderer' || !window.document) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the best feature-detection for react-native though? Seems fragile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can do navigator.product === 'ReactNative' too.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the point wasn't just to detect react-native, but to detect a lack of window.document which is used in the next part of the check.

return true;
}

Expand Down