Skip to content

Commit c51097f

Browse files
committed
test(test-app): remount the eager list on every run and describe the context seed
1 parent f133b08 commit c51097f

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎examples/test-app/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ agent-device react-devtools profile stop
253253
| --- | --- | --- |
254254
| `expensive-render` | `PriceHistoryChart` recomputes its trend on every render | `slow-render PriceHistoryChart` |
255255
| `memo-defeated` | `ContactList` passes a new callback and style object to memoized rows | `memo-defeated ContactRow` |
256-
| `context-cascade` | `SessionProvider` builds a new context value on every update | `context-cascade AvatarBadge` |
256+
| `context-cascade` | A fast-changing `unread` counter shares one context with the stable user name that badges read | `context-cascade AvatarBadge` |
257257
| `parent-cascade` | Typing re-renders every unmemoized result row | `parent-cascade ResultRow` |
258258
| `render-storm` | `LiveClock` sets state every 16 ms | `render-storm LiveClock` |
259259
| `effect-chain` | `FilteredContacts` copies derived state in an effect | `effect-chain FilteredContacts` |
260-
| `eager-list` | 1,200 tiles mount in one commit instead of a virtualized list | `eager-mount ProductTile` |
260+
| `eager-list` | 1,200 tiles mount in one commit instead of a virtualized list; every Run mounts them afresh | `eager-mount ProductTile` |
261261

262262
`src/screens/PerfLabScreen.tsx` imports only React and React Native, so it can be copied into a bare React Native app to check the profiler on other React Native versions.
263263

‎examples/test-app/src/screens/PerfLabScreen.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ const ContactRow = memo(function ContactRow({
180180
);
181181
});
182182

183-
// context-cascade: the provider value is a new object on every tick, so every badge re-renders
184-
// even though only the unrelated `unread` counter changes.
183+
// context-cascade: the context carries a fast-changing `unread` counter next to the stable `user`
184+
// name, so every badge that reads only `user` re-renders on each `unread` change.
185185
type Session = { user: string; unread: number };
186186
const SessionContext = createContext<Session>({ user: 'guest', unread: 0 });
187187

@@ -295,11 +295,13 @@ function FilteredContacts({ items }: { items: Contact[] }) {
295295

296296
// eager-list: showing the catalog mounts every tile at once instead of virtualizing the list.
297297
function EagerListScenario({ runId, onDone }: ScenarioProps) {
298-
const [shown, setShown] = useState(false);
299-
useBurst(runId, 1, 50, () => setShown((value) => !value), onDone);
298+
const [mountedRun, setMountedRun] = useState(0);
299+
useBurst(runId, 1, 50, () => setMountedRun(runId), onDone);
300300
return (
301301
<ScrollView style={styles.list}>
302-
{shown ? CATALOG.map((id) => <ProductTile id={id} key={id} />) : null}
302+
{runId > 0 && mountedRun === runId
303+
? CATALOG.map((id) => <ProductTile id={id} key={id} />)
304+
: null}
303305
</ScrollView>
304306
);
305307
}

0 commit comments

Comments
 (0)