B. A full screen with centered blue text 'Welcome!'
C. An error because styles are not applied correctly
D. A small box with black text 'Welcome!' at top left
Solution
Step 1: Analyze the container style
The container uses flex:1 to fill screen and centers content vertically and horizontally.
Step 2: Analyze the text style
The text has font size 24 and blue color, so it will appear large and blue.
Final Answer:
A full screen with centered blue text 'Welcome!' -> Option B
Quick Check:
Centered blue text = D [OK]
Hint: flex:1 + center styles = centered content [OK]
Common Mistakes:
Assuming text is black by default
Thinking styles cause errors
Ignoring flexbox centering
4. Identify the error in this React Native code snippet:
import React from 'react';
import { View, Text } from 'react-native';
export default function App() {
return (
Hello
World
);
}
const styles = StyleSheet.create({
container: { flex: 1 }
});
medium
A. The code is correct and will render 'Hello' and 'World'.
B. Multiple <Text> components inside <View> are not allowed.
C. Missing import of StyleSheet causes error.
D. The <View> tag is not closed properly.
Solution
Step 1: Check imports and usage
The code uses StyleSheet.create but does not import StyleSheet from 'react-native'.
Step 2: Verify JSX structure
Multiple <Text> inside <View> is allowed and <View> is properly closed.
Final Answer:
Missing import of StyleSheet causes error. -> Option C
Quick Check:
Missing StyleSheet import = A [OK]
Hint: Import all used modules like StyleSheet [OK]
Common Mistakes:
Thinking multiple <Text> tags are invalid
Ignoring missing imports
Assuming JSX tags are not closed
5. You want to create a polished React Native app with a button that changes color smoothly when pressed. Which approach best achieves this advanced UI effect?
hard
A. Use TouchableOpacity with animated opacity change on press.
B. Use a simple Button component with no animation.
C. Change button color instantly without animation on press.
D. Use Text component styled as a button without interaction.
Solution
Step 1: Identify how to animate button color on press