()
| 30 | } |
| 31 | |
| 32 | export function usePlatform() { |
| 33 | const [platform, setPlatform] = useState<PlatformType>("unknown") |
| 34 | |
| 35 | useEffect(() => { |
| 36 | const frame = window.requestAnimationFrame(() => { |
| 37 | setPlatform(detectPlatform()) |
| 38 | }) |
| 39 | |
| 40 | return () => { |
| 41 | window.cancelAnimationFrame(frame) |
| 42 | } |
| 43 | }, []) |
| 44 | |
| 45 | return { |
| 46 | platform, |
| 47 | isMac: platform === "macos", |
| 48 | isWindows: platform === "windows", |
| 49 | isLinux: platform === "linux", |
| 50 | } |
| 51 | } |
no test coverage detected