useOs
useOs (운영체제 감지)
useOs 훅은 사용자의 운영체제를 반환해요. 가능한 값은 undetermined, macos, ios, windows, android, linux, chromeos예요.
출처: 문서
본문
useOs 훅은 사용자의 운영체제를 반환해요. 가능한 값은 undetermined, macos, ios, windows, android, linux, chromeos예요. 예를 들어 서버 사이드 렌더링 중처럼 운영체제를 식별할 수 없으면 undetermined를 반환해요.
import { useOs } from '@mantine/hooks';
function Demo() {
const os = useOs();
return <>Your os is {os}</>;
}
정의 (Definition)
type UseOSReturnValue =
| 'undetermined'
| 'macos'
| 'ios'
| 'windows'
| 'android'
| 'linux'
| 'chromeos';
interface UseOsOptions {
getValueInEffect: boolean;
}
function getOS(options?: UseOsOptions): UseOSReturnValue;
Exported types
UseOsOptions와 UseOSReturnValue 타입은 @mantine/hooks 패키지에서 내보내져요.
import type { UseOsOptions, UseOSReturnValue } from '@mantine/hooks';
더 알아보기 (Learn more)
- useNetwork — 네트워크 상태
- usePageLeave — 페이지 이탈 감지