Skip to content

Commit

Permalink
Don't use ShadowNodeFragment::Value (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-piasecki authored Aug 31, 2024
1 parent 037a1b0 commit a02d4fa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace react {
extern const char MarkdownTextInputDecoratorViewComponentName[] =
"MarkdownTextInputDecoratorView";

const ShadowNodeFragment::Value
const OwningShadowNodeFragment
MarkdownTextInputDecoratorShadowNode::updateFragmentState(
ShadowNodeFragment const &fragment,
ShadowNodeFamily::Shared const &family) {
Expand All @@ -24,12 +24,12 @@ MarkdownTextInputDecoratorShadowNode::updateFragmentState(
// propagated on every clone we need it to clear the reference in the registry
// when the view is removed from window it cannot be done in the destructor,
// as multiple shadow nodes for the same family may be created
return ShadowNodeFragment::Value({
return OwningShadowNodeFragment{
.props = fragment.props,
.children = fragment.children,
.state =
std::make_shared<const ConcreteState>(newStateData, *fragment.state),
});
};
}

} // namespace react
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
namespace facebook {
namespace react {

struct OwningShadowNodeFragment {
Props::Shared props;
ShadowNode::SharedListOfShared children;
State::Shared state;

operator ShadowNodeFragment() const {
return ShadowNodeFragment {
.props = props,
.children = children,
.state = state
};
}
};

JSI_EXPORT extern const char MarkdownTextInputDecoratorViewComponentName[];

class JSI_EXPORT MarkdownTextInputDecoratorShadowNode final
Expand All @@ -22,8 +36,7 @@ class JSI_EXPORT MarkdownTextInputDecoratorShadowNode final
MarkdownTextInputDecoratorShadowNode(ShadowNodeFragment const &fragment,
ShadowNodeFamily::Shared const &family,
ShadowNodeTraits traits)
: ConcreteViewShadowNode(static_cast<ShadowNodeFragment>(
updateFragmentState(fragment, family)),
: ConcreteViewShadowNode(updateFragmentState(fragment, family),
family, traits) {}

MarkdownTextInputDecoratorShadowNode(ShadowNode const &sourceShadowNode,
Expand All @@ -37,7 +50,7 @@ class JSI_EXPORT MarkdownTextInputDecoratorShadowNode final
}

private:
static const ShadowNodeFragment::Value
static const OwningShadowNodeFragment
updateFragmentState(ShadowNodeFragment const &fragment,
ShadowNodeFamily::Shared const &family);
};
Expand Down

0 comments on commit a02d4fa

Please sign in to comment.