diff --git a/React/Views/RCTShadowView.m b/React/Views/RCTShadowView.m index 2e7d4794c..67b954da2 100644 --- a/React/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -165,10 +165,17 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT], if (!YGNodeGetHasNewLayout(node)) { return; } - YGNodeSetHasNewLayout(node, false); RCTAssert(!YGNodeIsDirty(node), @"Attempt to get layout metrics from dirtied Yoga node."); + YGNodeSetHasNewLayout(node, false); + + if (YGNodeStyleGetDisplay(node) == YGDisplayNone) { + // If the node is hidden (has `display: none;`), its (and its descendants) + // layout metrics are invalid and/or dirtied, so we have to stop here. + return; + } + #if RCT_DEBUG // This works around a breaking change in Yoga layout where setting flexBasis needs to be set explicitly, instead of relying on flex to propagate. // We check for it by seeing if a width/height is provided along with a flexBasis of 0 and the width/height is laid out as 0.