React Native React Native Core Components & APIs 2 — Questions and Answers
Question 1: Which component should you use to display images from a URL in React Native?
- Img
- Image (Correct answer)
- Picture
- Photo
Correct answer: Image
The Image component in React Native handles both local and remote image rendering with props like source and resizeMode.
Question 2: What is the purpose of the Modal component in React Native?
- To animate transitions
- To display content in a layer above the main view (Correct answer)
- To create navigation drawers
- To manage app state
Correct answer: To display content in a layer above the main view
Modal presents content in a full-screen overlay on top of the enclosing view, blocking interaction with the content behind.
Question 3: Which React Native component is used for single-line user text input?
- Input
- TextInput (Correct answer)
- TextField
- InputField
Correct answer: TextInput
TextInput is the standard React Native component for capturing text from the user's keyboard.
Question 4: What does the resizeMode prop control on a React Native Image component?
- Image file compression
- How the image scales to fit its container (Correct answer)
- Image loading priority
- Image border radius
Correct answer: How the image scales to fit its container
resizeMode determines how an image is resized relative to its container using values like cover, contain, stretch, or center.
Question 5: Which API in React Native is used to show native alert dialogs?
- Dialog
- Alert (Correct answer)
- Notification
- Prompt
Correct answer: Alert
The Alert API launches a native dialog with a title, message, and optional buttons on both iOS and Android.
Question 6: What is the purpose of ActivityIndicator in React Native?
- Tracks user activity logs
- Displays a loading spinner (Correct answer)
- Monitors network requests
- Records performance metrics
Correct answer: Displays a loading spinner
ActivityIndicator renders a circular loading indicator to show the user that something is in progress.
Which component should you use to display images from a URL in React Native?