| Files | Last commit | Last update |
|---|---|---|
| 25 days ago | ||
| 3 days ago | ||
| 1 year ago | ||
| 5 hours ago | ||
| 5 hours ago |
Description
This is a demo project using TurboModule.
Directory Structure
using_turboModule
├── SampleProject RN project
├── SampleApp Native project
└── screenshots Screenshots
Environment Setup
- In the
SampleProject/MainProjectdirectory, run pnpm i to install dependencies, then run pnpm dev to generate the bundle; - Open
SampleAppin DevEco Studio and wait for the automatic project synchronization to complete (for manual synchronization, execute Sync and Refresh Project); - Click File > Project Structure > Signing Configs, log in and complete the signing;
- Click run in the upper right corner of DevEco Studio to start the project;
NOTE: The project uses the latest RNOH dependencies by default during installation. If you need to install a specific version, please refer to RNOH Community Edition Roadmap to get the version number.
pnpm dependency installation:
pnpm i @react-native-oh/react-native-harmony@0.88.xxpnpm i --save-dev @react-native-oh/react-native-harmony-cli@0.88.xxohpm dependency installation:
ohpm i @rnoh/react-native-openharmony@0.88.xx
Preview
The page effect after startup is as follows:

- Click the 【•Call TurboModule callback method:】 button, and the return result (... from native side) will be filled back to the button;
- Click the 【•Call TurboModule async callback method:】 button, and the return result (rejected on native side) will be filled back to the button;
- Click the 【•Call native console.log method】 button, and logs will be printed in the DevEco console (print logs in Native);
- Click the 【•Call TurboModule2's test method】 button, and an alert dialog will appear on the phone interface, prompting "Call SampleTurboModule2's Test";
- Click the 【•Call TurboModule2's getObject method】 button, and an alert dialog will appear on the phone interface, prompting "{ "x": 100 }";
- Click the 【•Call TurboModule2's getRequest method】 button, and an alert dialog will appear on the phone interface, printing the content returned by the network request;
- Click the 【•Call TurboModule2's eatFruit method】 button, and an alert dialog will appear on the phone interface, prompting "Eating fruit, big pineapple is delicious. What about the color? Transparent";
- Click the 【•Call TurboModule2's checkPwd method】 button, and an alert dialog will appear on the phone interface, prompting "checkPwd success!";
- Click the 【•Call WorkerTurboModule callback method:】 button, and the return result (... from native worker side) will be filled back to the button;
- Click the 【•Call WorkerTurboModule async callback method:】 button, and the return result (rejected on native worker side) will be filled back to the button;
- Click the 【•Call native console.log method in worker thread:】 button, and logs will be printed in the DevEco console (print logs in Native's worker thread).