Skip to content

Commit

Permalink
feat: More docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Jan 15, 2025
1 parent 975381f commit f07f197
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion packages/nitrogen/src/views/ViewComponentShadowNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,21 @@ namespace ${namespace} {
public:
explicit ${stateClassName}() = default;
};
/**
* The Shadow Node for the "${spec.name}" View.
*/
using ${shadowNodeClassName} = react::ConcreteViewShadowNode<${nameVariable}, ${propsClassName}, react::ViewEventEmitter, ${stateClassName}>;
/**
* The Shadow Node descriptor for the "${spec.name}" View.
* The Component Descriptor for the "${spec.name}" View.
*/
class ${descriptorClassName}: public react::ConcreteComponentDescriptor<${shadowNodeClassName}> {
public:
${descriptorClassName}(const react::ComponentDescriptorParameters& parameters);
public:
void adopt(react::ShadowNode& shadowNode) const override;
};
/* The actual view for "${spec.name}" needs to be implemented in platform-specific code. */
Expand Down Expand Up @@ -158,6 +165,12 @@ namespace ${namespace} {
: ConcreteComponentDescriptor(parameters,
std::make_unique<react::RawPropsParser>(/* enableJsiParser */ true)) {}
void ${descriptorClassName}::adopt(react::ShadowNode& shadowNode) const {
// This is called immediately after \`ShadowNode\` is created, cloned or in progress.
auto& concreteShadowNode = static_cast<${shadowNodeClassName}&>(shadowNode);
const ${propsClassName}& props = concreteShadowNode.getConcreteProps();
}
} // namespace ${namespace}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ namespace margelo::nitro::image::views {
: ConcreteComponentDescriptor(parameters,
std::make_unique<react::RawPropsParser>(/* enableJsiParser */ true)) {}

void HybridTestViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
// This is called immediately after `ShadowNode` is created, cloned or in progress.
auto& concreteShadowNode = static_cast<HybridTestViewShadowNode&>(shadowNode);
const HybridTestViewProps& props = concreteShadowNode.getConcreteProps();
}

} // namespace margelo::nitro::image::views

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,21 @@ namespace margelo::nitro::image::views {
public:
explicit HybridTestViewState() = default;
};

/**
* The Shadow Node for the "TestView" View.
*/
using HybridTestViewShadowNode = react::ConcreteViewShadowNode<HybridTestViewComponentName, HybridTestViewProps, react::ViewEventEmitter, HybridTestViewState>;

/**
* The Shadow Node descriptor for the "TestView" View.
* The Component Descriptor for the "TestView" View.
*/
class HybridTestViewComponentDescriptor: public react::ConcreteComponentDescriptor<HybridTestViewShadowNode> {
public:
HybridTestViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);

public:
void adopt(react::ShadowNode& shadowNode) const override;
};

/* The actual view for "TestView" needs to be implemented in platform-specific code. */
Expand Down

0 comments on commit f07f197

Please sign in to comment.