Description
This is a demo project for creating custom Fabric components (including CAPI and ArkTS components).
Directory Structure
FabricComponentSample
├── ReactProject Front-end project
├── fabric-component-sample-package RN third-party component (custom Fabric component)
├── NativeProject OpenHarmony project
├── react-native-harmony RN OpenHarmony bundle
├── react-native-harmony-cli RN OpenHarmony scaffolding
└── README.md
Environment Setup
- Save
rnoh-react-native-harmony-xx.tgzto thereact-native-harmonyfolder and modify thereact-native-harmonydependency path ofReactProject/package.json. - Save
rnoh-react-native-harmony-cli-xx.tgzto thereact-native-harmony-clifolder. - Run npm pack in
fabric-component-sample-packageto generate a .tgz file. - Save
react_native_openharmony-xxx.harto theNativeProject/libsfolder and modify the dependency paths ofNativeProject/oh-package.json5andNativeProject/entry/oh-package.json5. - Open
NativeProjectin DevEco Studio and run Sync and Refresh Project. - Run npm i in
ReactProjectto install the dependency, run npm run dev to generate the bundle file, and run npm start to start Metro. - Go back to DevEco Studio and click File > Project Structure > Signing Configs, log in and complete the signing.
- Click run in the upper right corner to start the project.
- If Metro is started, run
hdc rport tcp:8081 tcp:8081to forward port 8081, and then restart the application on the mobile phone.