Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use ShadowNodeFragment::Value #426

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want an explicit or implicit conversion here?

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
Loading