From a02d4fad9ab7d86d28dcd80d783871cecd25630a Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Sat, 31 Aug 2024 07:26:06 +0200 Subject: [PATCH] Don't use `ShadowNodeFragment::Value` (#426) --- .../MarkdownTextInputDecoratorShadowNode.cpp | 6 +++--- .../MarkdownTextInputDecoratorShadowNode.h | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp index 104363d3..9240e9eb 100644 --- a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp +++ b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp @@ -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) { @@ -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(newStateData, *fragment.state), - }); + }; } } // namespace react diff --git a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.h b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.h index 294e0d3d..597752cb 100644 --- a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.h +++ b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.h @@ -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 @@ -22,8 +36,7 @@ class JSI_EXPORT MarkdownTextInputDecoratorShadowNode final MarkdownTextInputDecoratorShadowNode(ShadowNodeFragment const &fragment, ShadowNodeFamily::Shared const &family, ShadowNodeTraits traits) - : ConcreteViewShadowNode(static_cast( - updateFragmentState(fragment, family)), + : ConcreteViewShadowNode(updateFragmentState(fragment, family), family, traits) {} MarkdownTextInputDecoratorShadowNode(ShadowNode const &sourceShadowNode, @@ -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); };