Complete the code to import the Platform module from React Native.
import { [1] } from 'react-native';
The Platform module is used to detect the current platform (iOS or Android) in React Native.
Complete the code to apply a background color only on iOS using Platform.select.
const styles = StyleSheet.create({
container: {
backgroundColor: Platform.select({
ios: '[1]',
android: 'transparent'
})
}
});The backgroundColor will be red on iOS and transparent on Android.
Fix the error in the code to check if the platform is Android.
if (Platform.[1] === 'android') { console.log('Running on Android'); }
The correct property to check the platform name is Platform.OS.
Fill both blanks to create a style that uses different font sizes on iOS and Android.
const styles = StyleSheet.create({
text: {
fontSize: Platform.[1] === 'ios' ? [2] : 14
}
});The code checks if the platform is iOS using Platform.OS and sets font size to 16 for iOS, otherwise 14 for Android.
Fill all three blanks to create a style that uses Platform.select for margin and padding.
const styles = StyleSheet.create({
box: {
margin: Platform.select({ ios: [1], android: [2] }),
padding: Platform.select({ ios: [3], android: 10 })
}
});The margin is 15 on iOS and 20 on Android. The padding is 5 on iOS and 10 on Android.