Categories
React Native Answers

How to get the platform with React Native?

Spread the love

To get the platform the app is running on with React Native, we use the Platform.OS property.

For instance, we write

import { Platform, StyleSheet } from 'react-native';

const styles = StyleSheet.create({
  height: Platform.OS === 'ios' ? 200 : 100
});

to use the Platform.OS property to check if the platform is 'ios‘ when setting the height style.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *