usePlatform
React hook to tracked the platform of the user.
Usage
Live Editor
function Demo() { const {platform} = usePlatform(); return <p>platfrom: {platform}</p>; };
Result
Loading...
API
UsePlatformProps
Property | Description | Type | DefaultValue |
---|---|---|---|
userAgent | When server rendering, you need to pass userAgent | string | - |
usePlatform
Returns
UsePlatformReturn
: object that related to platform
Arguments
Argument | Description | Type | DefaultValue |
---|---|---|---|
props | - | UsePlatformProps | undefined | - |
UsePlatformReturn
Property | Description | Type | DefaultValue |
---|---|---|---|
platform | platform | Platform (Required) | - |
isInMiniProgram | Whether in mini program | () => boolean (Required) | - |
isInWechat | whether in wechat | () => boolean (Required) | - |
isiPhoneX | whether is iPhoneX | () => boolean (Required) | - |
Platform
export type Platform = 'ios' | 'android' | 'unknown';