diff --git a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js index 8e6b10479de7..5396edbdf2b3 100644 --- a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js +++ b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js @@ -12,14 +12,32 @@ import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; import RNTesterText from '../../components/RNTesterText'; import * as React from 'react'; -import {StyleSheet, View} from 'react-native'; +import {useState} from 'react'; +import {Pressable, StyleSheet, View} from 'react-native'; +// Repro for a recycled RCTViewComponentView keeping its custom container (iOS). +// Tap four times: +// 1. unmounts a view with overflow: 'hidden' + boxShadow; its native view is recycled. +// 2. mounts the bordered view, which dequeues that recycled view and mounts its +// children through the stale container. +// 3. replaces the second child: it lands BEHIND the first (green square hidden). +// 4. replaces it again; removing the old one asserts in debug builds: +// "Attempt to unmount a view which has a different index". +// Without the boxShadow on the first view, all four steps behave correctly. function Playground() { + const [step, setStep] = useState(0); return ( - - Edit "RNTesterPlayground.js" to change this file - + setStep(s => s + 1)} style={styles.button}> + {`Step ${step}: tap to advance`} + + {step === 0 && } + {step >= 2 && ( + + + + + )} ); } @@ -27,6 +45,40 @@ function Playground() { const styles = StyleSheet.create({ container: { padding: 10, + gap: 24, + }, + button: { + padding: 12, + backgroundColor: '#ddd', + }, + shadowClip: { + width: 120, + height: 120, + overflow: 'hidden', + boxShadow: '0px 4px 12px rgba(0,0,0,0.4)', + backgroundColor: 'white', + }, + bordered: { + width: 200, + height: 120, + borderTopWidth: 2, + borderTopColor: 'black', + }, + back: { + position: 'absolute', + top: 0, + left: 0, + right: 0, + bottom: 0, + backgroundColor: 'tomato', + }, + front: { + position: 'absolute', + top: 20, + left: 20, + width: 80, + height: 80, + backgroundColor: 'seagreen', }, });