Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(env): improve env detection compatibility for Node#1111

Merged
plainheart merged 3 commits into
ecomfe:masterfrom
liamjones:improve-nodejs-detection
Feb 17, 2025
Merged

fix(env): improve env detection compatibility for Node#1111
plainheart merged 3 commits into
ecomfe:masterfrom
liamjones:improve-nodejs-detection

Conversation

@liamjones
Copy link
Copy Markdown
Contributor

The React Native test environment is Node but sets up a window global: https://github.com/facebook/react-native/blob/7a85b911254dbae9fac4c6d8a862a20c33e0b36a/packages/react-native/Libraries/Core/setUpGlobals.js#L18

Reintroduce the navigator.userAgent check as a fallback for detecting a Node environment

The React Native test environment *is* Node but sets up a window global: https://github.com/facebook/react-native/blob/7a85b911254dbae9fac4c6d8a862a20c33e0b36a/packages/react-native/Libraries/Core/setUpGlobals.js#L18

Reintroduce the navigator.userAgent check as a fallback for detecting a Node environment
@liamjones
Copy link
Copy Markdown
Contributor Author

Without this tests in an RN environment fall over on this line:

const style = document.documentElement.style;

As there's a window but no document

Copy link
Copy Markdown
Collaborator

@plainheart plainheart left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

@plainheart plainheart merged commit aa71872 into ecomfe:master Feb 17, 2025
@liamjones liamjones deleted the improve-nodejs-detection branch February 17, 2025 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants