자바스크립트(javascript)
[react/javascript] 디바이스 / 브라우져 체크하기
개발자 고포고
2022. 11. 23. 16:03
반응형
[react/javascript] 디바이스 / 브라우져 체크하기
https://www.npmjs.com/package/react-device-detect
react-device-detect
Detect device type and render your component according to it. Latest version: 2.2.2, last published: 7 months ago. Start using react-device-detect in your project by running `npm i react-device-detect`. There are 762 other projects in the npm registry usin
www.npmjs.com
손쉽게 체크가능
#설치
npm install react-device-detect --save
#사용 크롬 체크
import React from "react";
import { isChrome} from "react-device-detect";
const IndexingPage = () => {
return isChrome ? <div>chrome yes</div> : <div>chrome no</div>;
};
export default IndexingPage;
#사용 아이폰 체크
import React from "react";
import { isAndroid, isIOS, isIOS13 } from "react-device-detect";
const IndexingPage = () => {
return isIOS ? <div>IOS</div> : <div>Android</div>;
};
export default IndexingPage;
#브라우저체크 #아이폰 체크 #리액트 #react
반응형