React Native Technology & Digital Applications 5 — Questions and Answers
Question 1: Which React Native API allows you to schedule a task to run in the background even when the app is not in the foreground?
- expo-background-fetch or react-native-background-fetch (Correct answer)
- setTimeout with a long delay
- AppState combined with AsyncStorage
- react-native's built-in BackgroundTask module
Correct answer: expo-background-fetch or react-native-background-fetch
Libraries like expo-background-fetch use native background task APIs on iOS and Android to run periodic background work.
Question 2: In React Native, how do you enable deep linking so the app opens to a specific screen from an external URL?
- Configure a URL scheme in app.json/Info.plist/AndroidManifest and handle the URL in a Linking event listener or React Navigation's linking config (Correct answer)
- Add a <DeepLink> component to the root navigator
- Set deep_link: true in the Metro configuration
- Use Fetch to intercept incoming requests at the native layer
Correct answer: Configure a URL scheme in app.json/Info.plist/AndroidManifest and handle the URL in a Linking event listener or React Navigation's linking config
Deep linking requires registering a URL scheme natively and then parsing incoming URLs—typically via React Navigation's linking prop or the Linking API.
Question 3: What is the recommended way to securely store sensitive data like API tokens in a React Native app?
- expo-secure-store or react-native-keychain, which use the OS keystore/keychain (Correct answer)
- AsyncStorage with AES encryption applied in JavaScript
- A hardcoded constant in a .env file bundled with the app
- The app's SQLite database with WAL mode enabled
Correct answer: expo-secure-store or react-native-keychain, which use the OS keystore/keychain
expo-secure-store and react-native-keychain store secrets in iOS Keychain or Android Keystore, which are hardware-backed secure enclaves.
Question 4: Which React Native prop on Image controls how an image is scaled within its container?
- resizeMode (Correct answer)
- objectFit
- scalingMode
- contentMode
Correct answer: resizeMode
The resizeMode prop accepts 'cover', 'contain', 'stretch', 'repeat', or 'center' to control how the image fills its bounds.
Question 5: What is the purpose of `react-native-gesture-handler` in a React Native project?
- It processes touch gestures on the UI thread for lower latency and better composability than the built-in touch system (Correct answer)
- It replaces the Animated API with gesture-driven animations
- It provides accessibility gesture support for screen readers
- It polyfills Web touch events for WebView content
Correct answer: It processes touch gestures on the UI thread for lower latency and better composability than the built-in touch system
react-native-gesture-handler moves gesture recognition to the native UI thread, avoiding the JS bridge overhead that causes dropped frames during fast swipes.
Question 6: How can you inspect the component tree and state of a running React Native app during development?
- React DevTools (standalone or browser extension) connected via the Metro dev server (Correct answer)
- Android Studio's Layout Inspector connected over ADB
- Xcode's View Debugger for both iOS and Android
- Safari Web Inspector on both platforms
Correct answer: React DevTools (standalone or browser extension) connected via the Metro dev server
The standalone React DevTools app connects to the Metro server and provides a live component tree, props, and state inspector for React Native.
Question 7: In React Native, what does the `AppState` API allow you to detect?
- Whether the app is in the foreground ('active'), background, or transitioning ('inactive' on iOS) (Correct answer)
- The amount of free memory available to the app process
- The current screen orientation of the device
- Whether the user has granted notification permissions
Correct answer: Whether the app is in the foreground ('active'), background, or transitioning ('inactive' on iOS)
AppState fires change events with values 'active', 'background', or 'inactive' so you can pause timers or sync data when the app moves to the background.
Which React Native API allows you to schedule a task to run in the background even when the app is not in the foreground?