react-native-device-detection
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

react-native-device-detection

About

The class was written to simplify the process of determining what platform was currently running to easily change Styles or JSX as needed.

Install

npm install react-native-device-detection --save

Usage

Import into a project file:

Require Import: const Device = require('react-native-device-detection');

ES6 Modules: import { isAndroid } from 'react-native-device-detection;

Then you can make changes to your StyleSheet like so:

if(Device.isIos) {
  Object.assign(styles, {
    ...
  });
}

or

if(Device.isTablet) {
  Object.assign(styles, {
    ...
  });
}

You can also use it anywhere else in your code where you need to differentiate between platforms.

Available props:

  • pixelDensity
  • width
  • height
  • isIos
  • isAndroid
  • isPhone
  • isTablet
  • isIphoneX

/react-native-device-detection/

    Package Sidebar

    Install

    npm i react-native-device-detection

    Weekly Downloads

    1,706

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    4.57 kB

    Total Files

    5

    Last publish

    Collaborators

    • m0ngr31