From ec757d9c8c226a90768fcee0a7ebcf9d9efbfdc7 Mon Sep 17 00:00:00 2001 From: Shubh Porwal Date: Fri, 30 Oct 2026 20:25:46 +0530 Subject: [PATCH] Add a Fantom test for `display: none` subtrees not being cloned again Tests that a hidden subtree isn't cloned on every commit that lays out its parent, through React commits and setNativeProps, and that hidden screens lay out the same as never-hidden ones once shown again. The second test depends on react/yoga#2055 and fails until that change is synced into the vendored copy of Yoga. Co-Authored-By: Claude Opus 5.5 --- .../__tests__/View-hiddenSubtrees-itest.js | 208 ++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 packages/react-native/Libraries/Components/View/__tests__/View-hiddenSubtrees-itest.js diff --git a/packages/react-native/Libraries/Components/View/__tests__/View-hiddenSubtrees-itest.js b/packages/react-native/Libraries/Components/View/__tests__/View-hiddenSubtrees-itest.js new file mode 100644 index 000000000000..858a32e038ad --- /dev/null +++ b/packages/react-native/Libraries/Components/View/__tests__/View-hiddenSubtrees-itest.js @@ -0,0 +1,208 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; + +import * as Fantom from '@react-native/fantom'; +import * as React from 'react'; +import {Text, View} from 'react-native'; + +type ScreenState = { + rows: number, + label: string, + nestedHidden: boolean, + absolute: boolean, +}; + +function Screen({ + hidden, + state, +}: { + hidden: boolean, + state: ScreenState, +}): React.Node { + const rows = []; + for (let i = 0; i < state.rows; i++) { + rows.push( + + + + + + {state.label} {i} + + + + , + ); + } + return ( +