A native module is a piece of code written in the platform's native language (like Java/Kotlin for Android or Objective-C/Swift for iOS) that can be called from React Native JavaScript code to access features not available in React Native by default.
Click to reveal answer
beginner
Why do React Native apps sometimes need native modules?
Because React Native does not cover all device features or platform-specific APIs, native modules let developers add those missing capabilities by bridging native code with JavaScript.
Click to reveal answer
intermediate
How do native modules improve app performance?
Native modules run directly on the device's native platform, so they can perform heavy or complex tasks faster than JavaScript code running in React Native.
Click to reveal answer
beginner
Give an example of a feature that might require a native module.
Accessing the device's camera, fingerprint sensor, or Bluetooth functionality often requires native modules because these features need platform-specific code.
Click to reveal answer
intermediate
What is the role of the bridge in React Native native modules?
The bridge connects JavaScript code with native code, allowing communication between them so native modules can be called from React Native and return results back.
Click to reveal answer
Why do React Native apps use native modules?
ATo access device features not available in React Native by default
BTo write all app code in JavaScript only
CTo avoid using any native platform code
DTo make the app slower
✗ Incorrect
Native modules let React Native apps use device features or platform APIs that React Native does not support out of the box.
Which languages are native modules typically written in for Android and iOS?
AJava/Kotlin for Android and Objective-C/Swift for iOS
BJavaScript and TypeScript
CPython and Ruby
DHTML and CSS
✗ Incorrect
Native modules use platform-specific languages: Java or Kotlin for Android, and Objective-C or Swift for iOS.
What does the React Native bridge do?
ARuns the app only on web browsers
BConnects JavaScript code with native platform code
CCompiles JavaScript into native code automatically
DPrevents communication between native and JavaScript code
✗ Incorrect
The bridge allows JavaScript and native code to communicate, enabling native modules to be used in React Native.
Which of these is NOT a reason to use native modules?
AAccessing hardware features like camera or sensors
BImproving performance for complex tasks
CWriting UI components in JavaScript
DUsing platform-specific APIs
✗ Incorrect
UI components are usually written in JavaScript with React Native; native modules are for accessing features outside React Native's default scope.
What happens if you try to use a device feature not supported by React Native without a native module?
AThe app will crash immediately
BThe app will run faster
CReact Native will automatically add support
DThe feature will not work or be accessible
✗ Incorrect
Without native modules, unsupported device features cannot be accessed from React Native code.
Explain in your own words why native modules are important in React Native development.
Think about what React Native cannot do alone and how native code helps.
You got /3 concepts.
Describe how the React Native bridge works with native modules to enable app features.
Imagine the bridge as a messenger between two languages.
You got /3 concepts.
Practice
(1/5)
1. Why do React Native apps use native modules?
easy
A. To make the app slower and less efficient
B. To write all app code in JavaScript only
C. To avoid using any native platform code
D. To access device features not available in JavaScript
Solution
Step 1: Understand React Native limitations
JavaScript in React Native cannot access all device hardware or native libraries directly.
Step 2: Role of native modules
Native modules bridge JavaScript with native platform code to access those features.
Final Answer:
To access device features not available in JavaScript -> Option D
Quick Check:
Native modules = access device features [OK]
Hint: Native modules add device features JavaScript lacks [OK]
Common Mistakes:
Thinking native modules replace JavaScript code
Believing native modules slow down the app
Assuming native modules are optional for all features
2. Which of the following is the correct way to import a native module in React Native?
easy
A. import { NativeModules } from 'react-native';
B. import NativeModules from 'react-native';
C. require('NativeModules');
D. import NativeModules from 'native-modules';
Solution
Step 1: Recall React Native import syntax
NativeModules is a named export from 'react-native', so it must be imported with curly braces.
Step 2: Check each option
import { NativeModules } from 'react-native'; uses correct syntax with curly braces; others are incorrect or invalid module names.
Final Answer:
import { NativeModules } from 'react-native'; -> Option A
Quick Check:
Correct import uses curly braces [OK]
Hint: Use curly braces to import named exports [OK]
Common Mistakes:
Omitting curly braces for named imports
Using wrong module names
Using require without assignment
3. What will the following React Native code output if the native module 'DeviceInfo' returns the device name 'Pixel 5'?
The native module 'DeviceInfo' calls the callback with the device name 'Pixel 5'.
Step 2: Check console.log output
The callback logs 'Device: Pixel 5' to the console.
Final Answer:
Device: Pixel 5 -> Option A
Quick Check:
Callback logs device name correctly [OK]
Hint: Callbacks print native data as expected [OK]
Common Mistakes:
Assuming synchronous return instead of callback
Expecting undefined if native module not linked
Confusing function names or parameters
4. You wrote this code to use a native module but get an error: TypeError: NativeModules.CameraModule.getPicture is not a function. What is the most likely cause?
medium
A. You forgot to import React
B. JavaScript syntax error in your code
C. The native module is not properly linked or registered
D. You used the wrong variable name for NativeModules
Solution
Step 1: Analyze the error message
The error says the function does not exist on the native module object.
Step 2: Understand native module linking
If the native module is not linked or registered correctly, its functions won't be available in JavaScript.
Final Answer:
The native module is not properly linked or registered -> Option C
Quick Check:
Linking issues cause missing native functions [OK]
Hint: Check native module linking if functions missing [OK]
Common Mistakes:
Assuming import errors cause this
Ignoring native build steps
Confusing variable names with linking problems
5. You want to create a React Native app that uses a native module to access the phone's biometric sensor for fingerprint authentication. Which of the following is the best approach?
hard
A. Write all biometric code in JavaScript without native modules
B. Use a native module to connect JavaScript with the platform's biometric API
C. Use only React Native UI components without any native code
D. Use a web API inside a WebView for biometric access
Solution
Step 1: Identify biometric sensor access needs
Biometric sensors require native platform APIs not accessible directly from JavaScript.
Step 2: Choose the correct integration method
Native modules bridge JavaScript with native biometric APIs for secure and efficient access.
Step 3: Evaluate other options
JavaScript alone or WebView cannot access biometric hardware securely or at all.
Final Answer:
Use a native module to connect JavaScript with the platform's biometric API -> Option B
Quick Check:
Native modules enable hardware access [OK]
Hint: Use native modules for hardware features like biometrics [OK]
Common Mistakes:
Trying to access hardware only with JavaScript
Ignoring security and platform API requirements
Using WebView for native hardware access
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.