Socket
Socket
Sign inDemoInstall

react-device-identifier

Package Overview
Dependencies
6
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-device-identifier

Load different components for Mobile and Desktop


Version published
Weekly downloads
23
increased by43.75%
Maintainers
1
Install size
10.7 kB
Created
Weekly downloads
 

Readme

Source

A lightweight library for loading components on the basis of device detection.

Purpose of creating this library

Sometimes we often create components different for Mobile, Tablets or Desktop and want them to get called respectively as per the device detection. Well the purpose of creating this library is to ease the debugging on development environment like when we debug our React application on Chrome browser with 'Toggle device toolbar' and change the device resolution, the respective components should get called.

If you don't find overhead of debugging such scenarios in their respective device resolutions like Tablets, Mobile or Desktop I highly recommend to use library react-device-detect instead of this one.

Examples

Import library

import DeviceIdentifier from 'react-device-identifier';

Run component only on Desktop

<DeviceIdentifier isDesktop={true}>
    // Desktop Component goes here
</DeviceIdentifier>

Run component only on Mobile

<DeviceIdentifier isMobile={true}>
    // Mobile Component goes here
</DeviceIdentifier>

Run component only on Tablet

<DeviceIdentifier isTablet={true}>
    // Tablet Component goes here
</DeviceIdentifier>

Run component for Mobile & Tablet

<DeviceIdentifier isMobile={true} isTablet={true}>
    // Tablet & Mobile Component goes here
</DeviceIdentifier>

We can make this more granular and can introduce more options like detecting low resolution tablets, But for now I kept it simple and covers the basic scenarios.

Feel free to send out pull request or can contact me directly via my eamil id nairabhijit6@gmail.com

Keywords

FAQs

Last updated on 20 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc