react-device-detector
Version:
React componant that renders based on device
57 lines (40 loc) • 1.07 kB
Markdown
Bare minimum device detector with no dependecy,
Renders components based on device
```bash
npm install react-device-detector
```
```bash
yarn add react-device-detector
```
```javascript
import {
AndroidView,
IOSView,
MobileView,
DesktopView,
} from "react-device-detector";
const MyComponent = () => {
return (
<>
<AndroidView>this will only render on android devices</AndroidView>
<IOSView>this will only render on iOS devices</IOSView>
<MobileView>this will only render on mobile</MobileView>
<DesktopView>this will only render on desktop</DesktopView>
</>
);
};
```
```javascript
import { isAndroid, isDesktop, isIOS, isMobile } from "react-device-detector";
const MyComponent = () => {
if (isMobile) return <p>this will only render on mobile</p>;
return <p>this will only render on desktop</p>;
};
```
If you have any new suggestions, new features, bug fixes, etc. please contribute by raising pull