Skip to content

Commit 0f7cc2b

Browse files
authored
React Events: check window before using navigator (facebook#15768)
1 parent ad9a6df commit 0f7cc2b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/react-events/src/Press.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ type PressEvent = {|
101101
shiftKey: boolean,
102102
|};
103103

104-
const isMac = /^Mac/.test(navigator.platform);
104+
const isMac =
105+
typeof window !== 'undefined' && window.navigator != null
106+
? /^Mac/.test(window.navigator.platform)
107+
: false;
105108
const DEFAULT_PRESS_END_DELAY_MS = 0;
106109
const DEFAULT_PRESS_START_DELAY_MS = 0;
107110
const DEFAULT_LONG_PRESS_DELAY_MS = 500;

0 commit comments

Comments
 (0)