Determine if on iPhone X in React Native
November 24, 2017
With the release of the iPhone X, I've found myself needing to have special conditions in a few of my React Native styles. Below is what I'm using to do that check.
import { Dimensions, Platform } from 'react-native';
export const isIphoneX = () => {
let d = Dimensions.get('window');
const { height, width } = d;
return (
// This has to be iOS duh
Platform.OS === 'ios' &&
// Accounting for the height in either orientation
(height === 812 || width === 812)
);
}
That's it! Easy as that.