คือการตรวจสอบอุปการณ์ ที่กำลังใช้อยู่ เช่น ใช้ Android หรือ iOS ในการเปิดหน้าเว็บไซต์
สามารถติดตั้ง จาก yarn หรือ npm ได้
yarn add react-navigator-user-agent
or
npm i -S react-navigator-user-agent
import {getOS, getPatform} from 'react-navigator-user-agent';
function App () {
return(
<div>
{getPatform() !== "Desktop" ? (
<div>
Mobile
</div>
): (
<div>
Desktop
</div>
)}
</div>
)
}
getOS();
-Android
-iOS
-Windows
-OS X
getPatform();
-Desktop -Mobile