Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 4d780b4

Browse files
committed
feat(hooks): add os detector
1 parent ddffecb commit 4d780b4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

components/Hooks/usePlatform.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const inialPlatform = {
99
isSafari: false,
1010
isIE: false,
1111
isEdge: false,
12+
isMacOS: false,
1213
}
1314

1415
// see https://stackoverflow.com/questions/49328382/browser-detection-in-reactjs/49328524
@@ -40,10 +41,18 @@ const usePlatform = (/* { breakpoint } */) => {
4041
const isChrome =
4142
!!Global.chrome && (!!Global.chrome.webstore || !!Global.chrome.runtime)
4243

44+
const isMacOS = Global.navigator.appVersion.indexOf('Mac') != -1
4345
/* eslint-enable */
4446

4547
setPlatform(
46-
R.merge(inialPlatform, { isFirefox, isSafari, isIE, isEdge, isChrome })
48+
R.merge(inialPlatform, {
49+
isFirefox,
50+
isSafari,
51+
isIE,
52+
isEdge,
53+
isChrome,
54+
isMacOS,
55+
})
4756
)
4857

4958
return () => {}

0 commit comments

Comments
 (0)