What does React Native use to create mobile apps for both iOS and Android?
React Native uses JavaScript and React to build apps that run on both iOS and Android platforms from a single codebase.
Click to reveal answer
beginner
How does React Native handle UI components across different platforms?
React Native provides a set of core components that map to native UI elements on each platform, so the app looks and feels native on both iOS and Android.
Click to reveal answer
intermediate
What role does the 'bridge' play in React Native?
The bridge connects JavaScript code with native platform code, allowing React Native to communicate with native APIs and components efficiently.
Click to reveal answer
beginner
Why is code reuse important in React Native for cross-platform development?
Code reuse means developers write one set of code that works on both iOS and Android, saving time and effort compared to building separate apps.
Click to reveal answer
intermediate
What advantage does React Native have over traditional native app development?
React Native allows faster development and easier maintenance by using a single codebase for multiple platforms, unlike traditional native apps that require separate codebases.
Click to reveal answer
Which language is primarily used to write React Native apps?
AJava
BSwift
CJavaScript
DKotlin
✗ Incorrect
React Native apps are mainly written in JavaScript, which allows cross-platform development.
What does React Native use to connect JavaScript with native platform features?
ACompiler
BAPI Gateway
CMiddleware
DBridge
✗ Incorrect
The bridge enables communication between JavaScript and native code in React Native.
How does React Native ensure apps look native on iOS and Android?
ABy using only Android UI components
BBy using platform-specific UI components
CBy compiling to native code directly
DBy using web views only
✗ Incorrect
React Native uses core components that map to native UI elements on each platform.
What is a key benefit of React Native's single codebase?
AFaster development for multiple platforms
BRequires separate code for iOS and Android
COnly works on Android
DNo access to native device features
✗ Incorrect
A single codebase allows developers to build apps faster for both iOS and Android.
Which of these is NOT true about React Native?
AIt requires writing separate apps for iOS and Android
BIt uses JavaScript and React
CIt uses a bridge to communicate with native code
DIt provides native-like UI components
✗ Incorrect
React Native does NOT require separate apps; it uses one codebase for both platforms.
Explain how React Native enables building apps for both iOS and Android using one codebase.
Think about how React Native connects JavaScript with native features and shares code.
You got /4 concepts.
Describe the role of the 'bridge' in React Native and why it is important for cross-platform apps.
Consider how JavaScript talks to the phone's native parts.
You got /3 concepts.
Practice
(1/5)
1. Why does React Native allow developers to create apps for both iOS and Android using mostly the same code?
easy
A. Because it runs the entire app inside a web browser on the device
B. Because it compiles JavaScript directly into native machine code for each platform
C. Because it requires writing separate code for iOS and Android but shares design files
D. Because it uses JavaScript to write shared code and renders native UI components on each platform
Solution
Step 1: Understand React Native's code sharing
React Native uses JavaScript to write most of the app logic once, which works on both iOS and Android.
Step 2: Recognize native UI rendering
It renders native UI components on each platform, so the app looks and feels native.
Final Answer:
Because it uses JavaScript to write shared code and renders native UI components on each platform -> Option D
Thinking React Native runs apps inside a web browser
Believing it compiles JS directly to machine code
Assuming separate code is needed for each platform
2. Which of the following is the correct way to import React Native components for cross-platform use?
easy
A. import View from 'react-native-view'; import Text from 'react-native-text';
B. import { View, Text } from 'react-native';
C. import { View, Text } from 'react';
D. import { View, Text } from 'react-native-web';
Solution
Step 1: Identify the official React Native import syntax
The correct way is to import components like View and Text from the 'react-native' package.
Step 2: Eliminate incorrect imports
Imports from wrong package names like 'react-native-view' (separate imports), 'react', or 'react-native-web' are not standard.
Final Answer:
import { View, Text } from 'react-native'; -> Option B
Quick Check:
Standard React Native imports use 'react-native' [OK]
Hint: Always import core components from 'react-native' package [OK]
Common Mistakes:
Importing from 'react' instead of 'react-native'
Using non-existent packages like 'react-native-view'
Confusing React Native with React Native Web imports
3. What will be the output on both iOS and Android when running this React Native code?
import React from 'react';
import { Text, View } from 'react-native';
export default function App() {
return (
Hello, cross-platform!
);
}
medium
A. A web page showing the text inside a browser
B. An error because View and Text cannot be used together
C. A native app screen showing the text 'Hello, cross-platform!' on both iOS and Android
D. A blank screen because the View component is empty
Solution
Step 1: Analyze the JSX structure
The code returns a View containing a Text component with the string 'Hello, cross-platform!'.
Step 2: Understand React Native rendering
View and Text are native components that render properly on both iOS and Android.
Final Answer:
A native app screen showing the text 'Hello, cross-platform!' on both iOS and Android -> Option C
Quick Check:
View + Text render native UI with text [OK]
Hint: View wraps Text to show content on both platforms [OK]
Common Mistakes:
Thinking View and Text cause errors when used together
Assuming the screen will be blank without styles
Confusing React Native with web rendering
4. Identify the error in this React Native code snippet that aims to display a button:
import React from 'react';
import { Button } from 'react-native';
export default function App() {
return (
);
}
medium
A. The title prop value is missing quotes, causing a syntax error
B. Button component cannot be used without a View wrapper
C. The import statement for Button is incorrect
D. React Native does not support Button component
Solution
Step 1: Check the Button component usage
The title prop value should be a string, so it must be enclosed in quotes.
Step 2: Identify the syntax error
title=Click Me is invalid; it should be title="Click Me" or title='Click Me'.
Final Answer:
The title prop value is missing quotes, causing a syntax error -> Option A
Quick Check:
Props with string values need quotes [OK]
Hint: Always put quotes around string prop values [OK]
Common Mistakes:
Omitting quotes around string props
Thinking Button needs a View wrapper to work
Believing Button is not a valid React Native component
5. You want to customize a React Native app so that a button looks different on iOS and Android but still share most code. Which approach best uses React Native's cross-platform features?
hard
A. Use Platform module to conditionally render different styles or components for each platform
B. Write two completely separate apps, one for iOS and one for Android
C. Use only web technologies and run the app in a browser on both devices
D. Use native code only and avoid React Native components
Solution
Step 1: Understand React Native's Platform module
The Platform module lets you detect the OS and apply platform-specific code or styles within the same app.
Step 2: Apply conditional rendering for customization
You can write shared code but customize UI parts like buttons differently for iOS and Android using Platform checks.
Final Answer:
Use Platform module to conditionally render different styles or components for each platform -> Option A