0
0
React Nativemobile~5 mins

Platform-specific styles in React Native - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of platform-specific styles in React Native?
Platform-specific styles allow you to customize the look and feel of your app separately for iOS and Android devices, making the app feel native on each platform.
Click to reveal answer
beginner
How do you import the module to detect the platform in React Native?
You import the Platform module using: <code>import { Platform } from 'react-native';</code>
Click to reveal answer
intermediate
Explain how to apply different styles for iOS and Android using the Platform.select method.
Use Platform.select({ ios: styleForIOS, android: styleForAndroid }) to choose styles based on the platform. This returns the style object for the current platform.
Click to reveal answer
intermediate
What is the difference between using Platform.OS and Platform.select for styling?
Platform.OS returns a string ('ios' or 'android') to use in conditional code. Platform.select is a helper that returns the correct value from an object based on the platform, simplifying style selection.
Click to reveal answer
advanced
Can you use platform-specific style files in React Native? How?
Yes. You can create separate style files named with platform extensions like styles.ios.js and styles.android.js. React Native automatically picks the right file based on the device platform.
Click to reveal answer
Which React Native module helps you detect the platform to apply styles?
ANavigator
BStyleSheet
CDimensions
DPlatform
What does Platform.OS return on an Android device?
A'android'
B'ios'
C'windows'
D'web'
How does Platform.select simplify platform-specific styling?
AIt automatically imports styles from external files.
BIt returns the style object matching the current platform from an object.
CIt converts styles to CSS.
DIt disables styles on unsupported platforms.
If you want to create separate style files for iOS and Android, what file naming convention should you use?
Astyles.ios.js and styles.android.js
Bstyles-ios.js and styles-android.js
Cstyles.js and styles.android.js
Dstyles_ios.js and styles_android.js
Which of these is NOT a recommended way to apply platform-specific styles in React Native?
ACreating separate style files with platform extensions
BUsing Platform.OS in conditional statements
CUsing CSS media queries
DUsing Platform.select in StyleSheet
Describe how you would apply different background colors for iOS and Android buttons in React Native.
Think about using Platform.select inside StyleSheet.create or a conditional expression.
You got /4 concepts.
    Explain the benefits of using platform-specific style files instead of inline platform checks.
    Consider how file naming helps React Native pick styles automatically.
    You got /4 concepts.