Add GraphNode example for Cxx TMs (#41766)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41766

Changelog: [Internal]

Adds a simple example showing a recursive node, stored inside a collection in a Cxx TM.

Currently we can't auto-generate [the necessary C++ Types](https://reactnative.dev/docs/next/the-new-architecture/cxx-custom-types#struct-generator) - but we can add it later if this scenarios becomes really common.

Reviewed By: rshest

Differential Revision: D51783974

fbshipit-source-id: 7352db1a354cd7da32febc650f7cc5e10dd16d2d
This commit is contained in:
Christoph Purrer
2023-12-04 04:19:47 -08:00
committed by Facebook GitHub Bot
parent 385473522c
commit 5754b4a123
4 changed files with 61 additions and 0 deletions
@@ -42,6 +42,8 @@ type Examples =
| 'getBool'
| 'getConstants'
| 'getCustomEnum'
| 'getCustomHostObject'
| 'getGraphNode'
| 'getNumEnum'
| 'getStrEnum'
| 'getMap'
@@ -102,6 +104,11 @@ class NativeCxxModuleExampleExample extends React.Component<{||}, State> {
NativeCxxModuleExample?.consumeCustomHostObject(
NativeCxxModuleExample?.getCustomHostObject(),
),
getGraphNode: () =>
NativeCxxModuleExample?.getGraphNode({
label: 'root',
neighbors: [{label: 'left'}, {label: 'right'}],
}),
getNumEnum: () => NativeCxxModuleExample?.getNumEnum(EnumInt.IB),
getStrEnum: () => NativeCxxModuleExample?.getStrEnum(EnumNone.NB),
getNumber: () => NativeCxxModuleExample?.getNumber(99.95),