Skip to content

Commit 18cfc3c

Browse files
authored
Adding support for ReactNative
ReactNative renders in a document-less mode, but goes through the browser for their live builds. Fortunately they tag the navigator as ReactNative making this easy to check for.
1 parent 5c7c61d commit 18cfc3c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/browser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ function useColors() {
124124
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
125125
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
126126
// Double check webkit in userAgent just in case we are in a worker
127-
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
127+
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)) ||
128+
// Check if we're being used in ReactNative
129+
(typeof navigator !== 'undefined' && navigator.product && navigator.product.toLowerCase() === 'reactnative');
128130
}
129131

130132
/**

0 commit comments

Comments
 (0)