Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

callstack/fabric-library-with-custom-cpp-example

Repository files navigation

Example fabric library with custom cpp state implementation

⚠️⚠️⚠️ UPDATE ⚠️⚠️⚠️

This repository has been archived in favour of official solution. Thanks to great efforts from the core team this temporary repository is no longer necessary.

Description

Probably you will not need this template, since fabric is responsible for whole synchronous measurements under the hood. But in some cases, your native component would like to update its frames in synchronous way. Right now, codegen does not support generating a new state based on typescript implementation, hence custom state implementation must be added manually. Linking custom cpp can be tricky, so together with @cortinico we prepared a showcase, so you can reuse this approach in your library. This example has been built on top of bob-builder

More context you can find here

How to generate shared cpp code

  • run codegen ./gradlew generateCodegenArtifactsFromSchema in android folder
  • copy everything under build/generated/source/codegen/jni/react/renderer/components/yourlib into cpp folder
  • pass interfaceOnly flag
  • run codegen once again
  • implement cpp state

How to link custom cpp state in RN 70?

Android

Here you can see how to make it: link. Instead of AndroidMkPath , please add CMakePath to react-native.config.js

iOS

Replace s.source_files = "ios/**/*.{h,m,mm}" with s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{h,cpp}" inside yourLib.podspec file and change imports inside .mm file

About

Add custom cpp state to your fabric library

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published