From 75676a2fe7431615ff72afac24e301cc8aa25f1b Mon Sep 17 00:00:00 2001 From: Akash Pandey Date: Wed, 9 Sep 2026 12:27:03 +0530 Subject: [PATCH] fix(fabric): prevent Yoga layout assertion crash in RNGestureHandlerDetectorShadowNode --- .../RNGestureHandlerDetectorShadowNode.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-gesture-handler/shared/shadowNodes/react/renderer/components/rngesturehandler_codegen/RNGestureHandlerDetectorShadowNode.cpp b/packages/react-native-gesture-handler/shared/shadowNodes/react/renderer/components/rngesturehandler_codegen/RNGestureHandlerDetectorShadowNode.cpp index 819a262acd..6d075a4666 100644 --- a/packages/react-native-gesture-handler/shared/shadowNodes/react/renderer/components/rngesturehandler_codegen/RNGestureHandlerDetectorShadowNode.cpp +++ b/packages/react-native-gesture-handler/shared/shadowNodes/react/renderer/components/rngesturehandler_codegen/RNGestureHandlerDetectorShadowNode.cpp @@ -72,9 +72,8 @@ void RNGestureHandlerDetectorShadowNode::layout(LayoutContext layoutContext) { // Default layout will reset the flag on child nodes. YogaLayoutableShadowNode::layout(layoutContext); - // No child had its layout changed, we can reuse previous values - if (!anyChildHasNewLayout) { - react_native_assert(previousLayoutMetrics_.has_value()); + // No child had its layout changed, we can reuse previous values if available + if (!anyChildHasNewLayout && previousLayoutMetrics_.has_value()) { setLayoutMetrics(previousLayoutMetrics_.value()); return; } @@ -101,6 +100,7 @@ void RNGestureHandlerDetectorShadowNode::layout(LayoutContext layoutContext) { metrics.frame.origin = Point{minX, minY}; metrics.frame.size = Size{maxX - minX, maxY - minY}; setLayoutMetrics(metrics); + previousLayoutMetrics_ = metrics; // Shift all children so their positions are relative to the detector's origin for (const auto &child : children) {