check platform in react native code example

Example 1: react native styles for both platforms

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

const styles = StyleSheet.create({
  container: {
    flex: 1,
    ...Platform.select({
      ios: {
        backgroundColor: 'red'
      },
      android: {
        backgroundColor: 'green'
      },
      default: {
        // other platforms, web for example
        backgroundColor: 'blue'
      }
    })
  }
});

Example 2: react native get OS

const design = Platform.select({
    android: {
      header: true
    },
    ios: {
	  header: false
    },
  });

Example 3: react native detect platform

Platform.select({
	ios: {
		backgroundColor: 'red',
	},
	android: {
		backgroundColor: 'blue',
	},
})