Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import a Turbo Module in React Native.
React Native
import { [1] } from 'react-native';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using NativeModules instead of TurboModuleRegistry
Importing unrelated hooks like useState
✗ Incorrect
Turbo Modules are accessed via TurboModuleRegistry in React Native.
2fill in blank
mediumComplete the code to get a Turbo Module named 'MyModule'.
React Native
const myModule = [1].get('MyModule');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using NativeModules.get instead of TurboModuleRegistry.get
Trying to call get on React or ModuleRegistry which don't exist
✗ Incorrect
TurboModuleRegistry.get('MyModule') returns the Turbo Module instance.
3fill in blank
hardFix the error in the Turbo Module method call to get a string result.
React Native
const result = await myModule.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using snake_case or incorrect capitalization
Calling a method name that does not exist
✗ Incorrect
Method names in Turbo Modules use camelCase like 'fetchData'.
4fill in blank
hardFill both blanks to define a Turbo Module interface with a method returning a Promise.
React Native
export interface [1] { [2](): Promise<string>; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect interface or method names
Not returning a Promise in the method signature
✗ Incorrect
The interface name is 'MyTurboModule' and method 'fetchData' returns a Promise.
5fill in blank
hardFill all three blanks to register a Turbo Module in native code (TypeScript style).
React Native
import { TurboModuleRegistry } from 'react-native'; const [1] = TurboModuleRegistry.get<[2]>('[3]');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up interface and variable names
Using wrong string name for the module
✗ Incorrect
We assign the module to 'myModule', use interface 'MyTurboModule', and get 'MyModule' by name.