diff --git a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js index d37d0d4a9154..19990d64c08a 100644 --- a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js +++ b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js @@ -12,27 +12,111 @@ 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 { + Button, + SectionList, + StyleSheet, + Text, + View, +} from 'react-native'; + +const INITIAL_SECTIONS = [ + {title: 'Section', data: [{key: 'a'}, {key: 'b'}, {key: 'c'}]}, +]; +const REORDERED_SECTIONS = [ + {title: 'Section', data: [{key: 'b'}, {key: 'a'}, {key: 'c'}]}, +]; + +function ItemSeparatorReproducer({leadingItem, trailingItem}: any) { + const leading = leadingItem?.key ?? 'undefined'; + const trailing = trailingItem?.key ?? 'undefined'; + return ( + + + leading: {leading} | trailing: {trailing} + + + ); +} + +function ItemSeparatorComponentBugPlayground() { + const [sections, setSections] = useState(INITIAL_SECTIONS); + const [reordered, setReordered] = useState(false); -function Playground() { return ( - Edit "RNTesterPlayground.js" to change this file + Bug: ItemSeparatorComponent receives stale leadingItem/trailingItem after + reorder. Tap "Reorder" to swap first two items. The separator between + "b" and "a" should show "leading: b | trailing: a". If it shows + "leading: a | trailing: c" or "undefined", the bug is present. +