Complete the code to import a native module in React Native.
import [1] from 'react-native';
The correct import to access native modules in React Native is NativeModules from 'react-native'.
Complete the code to access a native module named 'CalendarManager'.
const calendar = NativeModules.[1];Native module names are case sensitive and usually use PascalCase. The correct name is CalendarManager.
Fix the error in the code to call a native method 'addEvent' with parameters.
calendar.[1]('Birthday Party', '2024-07-01', (error, eventId) => { if (error) { console.error(error); } else { console.log('Event ID:', eventId); } });
Native method names are case sensitive and usually camelCase. The correct method name is addEvent.
Fill both blanks to correctly link a native library in React Native's Android build.gradle file.
implementation project(':[1]') apply from: '../../node_modules/react-native/[2].gradle'
The native library name in settings.gradle and build.gradle is usually the project name like mylibrary. The gradle script applied is react.gradle from react-native node_modules.
Fill all three blanks to correctly link a native iOS library in Podfile.
pod '[1]', :path => '../node_modules/[2]' post_install do |installer| installer.pods_project.targets.each do |target| if target.name == '[3]' target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO' end end end end
The pod name is usually PascalCase like RNMyLibrary. The path uses the npm package folder name rn-my-library. The target name matches the pod name RNMyLibrary.