Complete the code to import the native module in React Native.
import { [1] } from 'react-native';
The NativeModules object is used to access native modules in React Native.
Complete the code to call a native method named 'getDeviceName'.
NativeModules.DeviceInfo.[1]()The method to get the device name is called getDeviceName in the native module.
Fix the error in the code to correctly import and use a native module.
import { [1] } from 'react-native'; NativeModules.DeviceInfo.getDeviceName();
You must import NativeModules from 'react-native' to access native modules.
Fill both blanks to create a native module call that returns a promise.
NativeModules.DeviceInfo.[1]().then([2] => { console.log([2]); });
The method getDeviceName returns a promise. The result is captured in the result variable.
Fill all three blanks to define and export a simple native module in JavaScript.
import { [1] } from 'react-native'; const MyModule = { [2]: () => 'Hello from native!' }; export default [3];
We import NativeModules (even if unused here), define a method greet, and export the module as MyModule.