diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h index 1bd4e47e62e..2c1e0c7fa5d 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h @@ -26,6 +26,14 @@ class SafeAreaViewShadowNode final : public ConcreteViewShadowNode< ViewEventEmitter, SafeAreaViewState> { using ConcreteViewShadowNode::ConcreteViewShadowNode; + + public: + static ShadowNodeTraits BaseTraits() { + auto traits = ConcreteViewShadowNode::BaseTraits(); + traits.set( + ShadowNodeTraits::Trait::YogaLayoutableKindMutatesStylesAfterCloning); + return traits; + } }; } // namespace react diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 60f867e1ee0..4b4fee2b47e 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -82,6 +82,11 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( static_cast(sourceShadowNode) .yogaNode_.isDirty() == yogaNode_.isDirty()); + if (getTraits().check(ShadowNodeTraits::Trait:: + YogaLayoutableKindMutatesStylesAfterCloning)) { + yogaNode_.setDirty(true); + } + if (fragment.props) { updateYogaProps(); } diff --git a/ReactCommon/react/renderer/core/ShadowNodeTraits.h b/ReactCommon/react/renderer/core/ShadowNodeTraits.h index 16b7129bd00..d4b663406ca 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeTraits.h +++ b/ReactCommon/react/renderer/core/ShadowNodeTraits.h @@ -54,6 +54,12 @@ class ShadowNodeTraits { // Nodes with this trait (and all their descendants) will not produce views. Hidden = 1 << 6, + // Indicates that the `YogaLayoutableShadowNode` must set `isDirty` flag for + // Yoga node when a `ShadowNode` is being cloned. `ShadowNode`s that modify + // Yoga styles in the constructor (or later) *after* the `ShadowNode` + // is cloned must set this trait. + YogaLayoutableKindMutatesStylesAfterCloning = 1 << 7, + // Inherits `YogaLayoutableShadowNode` and enforces that the `YGNode` is a // leaf. LeafYogaNode = 1 << 10,