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?
✗ Incorrect
The Platform module provides information about the device platform (iOS or Android) to apply platform-specific styles.
What does
Platform.OS return on an Android device?✗ Incorrect
Platform.OS returns the string 'android' when running on an Android device.How does
Platform.select simplify platform-specific styling?✗ Incorrect
Platform.select takes an object with keys for each platform and returns the value for the current platform, making style selection easier.If you want to create separate style files for iOS and Android, what file naming convention should you use?
✗ Incorrect
React Native recognizes files named with platform extensions like
styles.ios.js and styles.android.js and loads the correct one automatically.Which of these is NOT a recommended way to apply platform-specific styles in React Native?
✗ Incorrect
CSS media queries are not used in React Native. Platform-specific styles are handled with Platform module or separate files.
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.