https://github.com/m0ngr31/react-native-device-detection
https://github.com/m0ngr31/react-native-device-detection
react-native
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/m0ngr31/react-native-device-detection
- Owner: m0ngr31
- License: mit
- Created: 2016-03-14T19:30:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-01-16T18:28:38.000Z (over 6 years ago)
- Last Synced: 2024-03-23T07:23:52.821Z (over 2 years ago)
- Topics: react-native
- Language: JavaScript
- Size: 13.7 KB
- Stars: 59
- Watchers: 3
- Forks: 19
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
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