Created
July 19, 2023 20:52
-
-
Save DWboutin/7cf15061157f2daf04ef1e25dd110b6a to your computer and use it in GitHub Desktop.
Detect apple device in React.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from "react" | |
export function useDetectAppleDevice() { | |
const isMac = /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent) | |
useEffect(() => { | |
if (isMac) { | |
document.documentElement.classList.add("apple-device") | |
} | |
}, [isMac]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment