An Expo module is a reusable package that adds native functionality to a React Native app using Expo. It helps you access device features like camera, sensors, or notifications easily.
Click to reveal answer
beginner
How do Expo modules simplify mobile app development?
Expo modules provide pre-built native code wrapped in JavaScript, so you don’t have to write native code yourself. This saves time and reduces complexity when adding device features.
Click to reveal answer
beginner
Name two common Expo modules and their purpose.
1. expo-camera: lets you take photos and record videos. 2. expo-location: provides access to the device’s GPS location.
Click to reveal answer
beginner
How do you install an Expo module in your React Native project?
Use the command `expo install ` in your project folder. This ensures you get the right version compatible with your Expo SDK.
Click to reveal answer
intermediate
What is the difference between managed and bare workflows in Expo regarding modules?
In managed workflow, Expo handles native code and modules for you, making it easier but less flexible. In bare workflow, you control native code and can add custom native modules.
Click to reveal answer
Which command installs an Expo module correctly?
Anpm install expo-module-camera
Bexpo install expo-camera
Cexpo add camera-module
Dnpm install react-native-camera
✗ Incorrect
Use `expo install ` to install Expo modules with the right version.
What does the expo-location module provide?
AAccess to device GPS location
BCamera access
CPush notifications
DFile system access
✗ Incorrect
expo-location gives your app access to the device's GPS location.
In which Expo workflow do you manage native code yourself?
ABare workflow
BManaged workflow
CExpo Go workflow
DNone of the above
✗ Incorrect
Bare workflow lets you control native code and add custom native modules.
Why use Expo modules instead of writing native code directly?
AThey are slower but easier
BThey only work on Android
CThey require manual linking
DThey provide pre-built native features accessible via JavaScript
✗ Incorrect
Expo modules wrap native code so you can use device features easily in JavaScript.
Which of these is NOT an Expo module?
Aexpo-camera
Bexpo-location
Creact-native-sensors
Dexpo-notifications
✗ Incorrect
react-native-sensors is a third-party library, not an official Expo module.
Explain what Expo modules are and how they help in React Native app development.
Think about how Expo modules act like ready-made tools for device features.
You got /3 concepts.
Describe the difference between managed and bare workflows in Expo regarding module usage.
Consider who controls the native code in each workflow.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of Expo modules in a React Native app?
easy
A. To create custom UI components from scratch
B. To write backend server code
C. To manage app navigation between screens
D. To easily add device features like camera and location
Solution
Step 1: Understand Expo modules role
Expo modules provide access to device features such as camera, location, and notifications.
Step 2: Compare options with this role
Only To easily add device features like camera and location matches this purpose; others relate to UI, navigation, or backend, which Expo modules do not handle.
Final Answer:
To easily add device features like camera and location -> Option D
Quick Check:
Expo modules = device features access [OK]
Hint: Expo modules = device features access, not UI or backend [OK]
Common Mistakes:
Confusing Expo modules with navigation libraries
Thinking Expo modules create UI components
Assuming Expo modules handle backend logic
2. Which is the correct way to import the Camera module from Expo in a React Native app?
easy
A. import { Camera } from 'expo-camera';
B. import Camera from 'react-native-camera';
C. import { Camera } from 'expo-device';
D. import Camera from 'expo-camera-module';
Solution
Step 1: Identify the official Expo Camera import
The correct import is from 'expo-camera' with named import { Camera }.
Step 2: Check other options for correctness
import Camera from 'react-native-camera'; uses a different library name, C imports from wrong module, D uses a non-existent module name.
Final Answer:
import { Camera } from 'expo-camera'; -> Option A
Quick Check:
Expo Camera import = { Camera } from 'expo-camera' [OK]
Hint: Expo modules import from 'expo-<feature>' with named imports [OK]
Common Mistakes:
Using default import instead of named import
Importing from wrong package name
Confusing Expo modules with React Native community packages
3. What will the following code output if the user denies camera permission?
import { Camera } from 'expo-camera';
import React, { useState, useEffect } from 'react';
export default function App() {
const [hasPermission, setHasPermission] = useState(null);
useEffect(() => {
(async () => {
const { status } = await Camera.requestCameraPermissionsAsync();
setHasPermission(status === 'granted');
})();
}, []);
if (hasPermission === null) {
return Requesting permission...;
}
if (hasPermission === false) {
return No access to camera;
}
return Camera access granted;
}
medium
A. Displays 'No access to camera'
B. Displays 'Requesting permission...' indefinitely
C. Displays 'Camera access granted'
D. Throws a runtime error
Solution
Step 1: Understand permission request flow
The code requests camera permission asynchronously and sets hasPermission to true if granted, false otherwise.
Step 2: Analyze user denies permission case
If user denies, status !== 'granted', so hasPermission is false, triggering the second if block to show 'No access to camera'.
Final Answer:
Displays 'No access to camera' -> Option A
Quick Check:
User denies permission = show 'No access to camera' [OK]
4. Identify the error in this Expo Location usage code:
import * as Location from 'expo-location';
import React, { useState, useEffect } from 'react';
export default function App() {
const [location, setLocation] = useState(null);
useEffect(() => {
(async () => {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
return;
}
let loc = await Location.getCurrentPositionAsync({});
setLocation(loc);
})();
}, []);
return location ? {JSON.stringify(location)} : Loading...;
}
medium
A. Using getCurrentPositionAsync without options
B. Using useState incorrectly with null initial value
C. Missing parentheses when calling requestForegroundPermissionsAsync
D. Not importing React properly
Solution
Step 1: Check async function calls
The code uses await Location.requestForegroundPermissionsAsync without parentheses, so it references the function instead of calling it.
Step 2: Verify other parts
useState with null is valid, React import is correct, getCurrentPositionAsync can be called with empty options object.
Final Answer:
Missing parentheses when calling requestForegroundPermissionsAsync -> Option C
Quick Check:
Async function call needs () to execute [OK]
Hint: Async calls need () after function name to run [OK]
Common Mistakes:
Forgetting () on async function calls
Assuming useState(null) is wrong
Thinking getCurrentPositionAsync requires options
5. You want to build a React Native app using Expo modules that shows the user's current location only if permission is granted. Which sequence of steps is correct?
hard
A. Request permission first, then import Location module, then get location
B. Import Location module, request permission, check status, get location if granted, display location
C. Import Location module, get location immediately, then request permission if needed
D. Display location first, then request permission, then import Location module
Solution
Step 1: Understand correct usage order
You must import the Location module first to use its functions.
Step 2: Request permission before accessing location
Request permission and check status before calling getCurrentPositionAsync to avoid errors.
Step 3: Only get and display location if permission is granted
This ensures app behaves correctly and respects user privacy.
Final Answer:
Import Location module, request permission, check status, get location if granted, display location -> Option B