Personally , I don't like using an external component to apply simple functions, so I decided that the user:
Using EXPO
The expo contains properties that help verify device information β https://docs.expo.io/versions/latest/sdk/constants.html#expoconstantsplatform , for iOS you can use:
import Expo from 'expo'; import React from 'react'; import { Text, View } from 'react-native'; class HomeComponent extends React.Component { render() { console.log(Expo.Constants.manifest); console.log(Expo.Constants.platform.ios.userInterfaceIdiom); return ( <View> <Text> {Expo.Constants.platform.ios.userInterfaceIdiom} </Text> </View> ); } }
Using the React-Native API
However, my application also runs in android, then I used the solution raised by @Alex Pavtoulov:
import React from 'react'; import { Text, View } from 'react-native'; const { height, width } = Dimensions.get('window'); const DeviceType = (height / width) > 1.6 ? 'Tablet' : 'Phone'; class HomeComponent extends React.Component { render() { return ( <View> <Text> This deice is: {DeviceType} </Text> </View> ); } }
source share