react-mobile-detect
Version:
React Mobile Detect
55 lines (34 loc) • 914 B
Markdown
mobile detect device for react component
implement from [react-device-detect](https://www.npmjs.com/package/react-device-detect) for my own work
To install, you can use npm or yarn:
```
npm i react-mobile-detect
or
yarn add react-mobile-detect
```
```
import {
BrowserView, // Modify this
MobileView, // Modify this
DetectMobileContextProvider
} from "react-mobile-detect";
<BrowserView/>
<MobileView/>
<DetectMobileContextProvider><App/></DetectMobileContextProvider>
const { isMobile } = useMobileDetect();
```
```
import dynamic from 'next/dynamic'
const BrowserView = dynamic(() => import('~/components/BrowserView'), { ssr: false })
const MobileView = dynamic(() => import('~/components/MobileView'), { ssr: false })
```
```
1. git clone https://github.com/zeing/react-mobile-detect.git
2. yarn
3. yarn start
```