<!-- PkgPulse AI-readable guide source -->
<!-- Canonical: https://www.pkgpulse.com/guides/legend-list-migration-react-native -->
<!-- Raw Markdown: https://www.pkgpulse.com/guides/legend-list-migration-react-native/raw.md -->
<!-- Source path: content/guides/legend-list-migration-react-native.mdx -->

---
title: "Migrate from FlashList to Legend List"
description: "Port a FlashList screen to Legend List in React Native. Check row sizing, recycled state, scroll restoration and keyboard taps with the same test fixture."
date: "2026-12-04"
author: "PkgPulse Team"
tags: ["list virtualization", "migration", "mobile interfaces"]
tileSubjects:
  - slug: shopify-flash-list
    name: FlashList
  - slug: legendapp-list
    name: Legend List
---

<!-- content-block--tldr -->
<!-- pipeline:claim c001 -->

To migrate a FlashList screen to Legend List, keep the rows, stable item IDs and enclosing React Native layout. Replace the list, let dynamic rows measure themselves and run the same screen with Legend List recycling off and on. Start by reopening the screen after inserting a row above your saved position. The same saved item should come back into view.

Use this port when you have a list regression to investigate or a reason to standardize on Legend List. Keep FlashList if the existing screen meets its requirements and the replacement introduces a jump, leaked row state or a missed tap. The fixture uses FlashList 2.3.3 and Legend List 3.9.2 on React Native 0.88.1 with React 19.3.1. FlashList v2 requires React Native's New Architecture. [Shopify's FlashList migration notes](https://shopify.github.io/flash-list/docs/v2-migration/)

## Port sizing and recycling separately

<!-- pipeline:claim c002 -->
<!-- pipeline:claim c003 -->

| Change | What to carry over |
| --- | --- |
| Native import | Install `@legendapp/list` and import the component from `@legendapp/list/react-native`. |
| Dynamic rows | Start without a size prop. FlashList v2 measures rows without caller estimates. Legend List uses measured sizes and averages after mount. |
| Initial estimate | In Legend List, `estimatedItemSize` is an optional hint before real measurements. `getEstimatedItemSize` was removed in v3. |
| Known fixed sizes | Legend List's `getFixedItemSize(item, index, type)` can return an exact size for a fixed row and `undefined` for a dynamic one. |
| Cell identity | Keep `keyExtractor` tied to the record ID. Keep `getItemType` if it represents distinct row layouts. |
| Cell reuse | FlashList recycles cells. Legend List leaves recycling off unless you pass `recycleItems={true}`. |

If your old FlashList code uses `overrideItemLayout`, check what it does before carrying it over. In FlashList v2 that callback sets column span. Older examples that set `layout.size` describe a different API. For a single-column feed with wrapping text, begin without an estimate. If landing on a distant item starts poorly, try an estimate based on measured rows and repeat the jump on device. Use a fixed-size callback only when styles and supported font sizes guarantee the height. A hard-coded height for text that wraps can make the initial position look plausible while leaving rows clipped. [FlashList v2 changes](https://shopify.github.io/flash-list/docs/v2-changes/) · [Legend List sizing](https://legendapp.com/open-source/list/v3/performance/)

An item's selection, draft or expansion belongs to its ID if it needs to survive scrolling away. The shared row in this fixture stores its mark in screen state keyed by ID. For state that should reset when a cell is reused, FlashList's `useRecyclingState` takes a dependency array, such as `[item.id]`. Legend List's hook of the same name takes an initial value or initializer and uses the current item identity from the row's list context. If you use either hook, call it inside a row component returned by `renderItem`. A reset hook clears transient state on reuse. It does not persist a draft for the next time that item appears. [FlashList recycling](https://shopify.github.io/flash-list/docs/recycling/) · [Legend List API](https://legendapp.com/open-source/list/v3/api/)

## Run the same inbox with either list

<!-- pipeline:claim c004 -->
<!-- pipeline:claim c005 -->

Use an existing TypeScript React Native app with New Architecture enabled and a bounded screen container. Install the two list packages in that app. The FlashList package also declares `@babel/runtime` as a peer. For exact fixture parity use the runtime versions above and `@babel/runtime@7.29.2`. Mount the component as a screen or use it as `App.tsx` in a test app. Keep the host's safe-area and keyboard settings the same for all runs.

```sh
bun add --exact @shopify/flash-list@2.3.3 @legendapp/list@3.9.2 @babel/runtime@7.29.2
```

The fixture renders the same mixed-height inbox in each mode. The input exercises the keyboard without changing the data. **Save and close** records the row you choose, unmounts the list and keeps the inbox state alive. Reopen the list to restore by ID against the new array order.

```tsx
import { useMemo, useRef, useState } from "react";
import { Button, Keyboard, Text, TextInput, View } from "react-native";
import { FlashList, type FlashListRef } from "@shopify/flash-list";
import { LegendList, type LegendListRef } from "@legendapp/list/react-native";

type Row = { id: string; kind: "ticket" | "note" };
type Mode = "flash" | "legend" | "legend-recycling";
const anchorId = "ticket-160";
const originalRows: Row[] = Array.from({ length: 240 }, (_, index) => ({
  id: `ticket-${index}`,
  kind: index % 3 === 0 ? "note" : "ticket",
}));
const insertedRow: Row = { id: "new-ticket", kind: "note" };
const keyExtractor = (row: Row) => row.id;
const getItemType = (row: Row) => row.kind;

function indexFor(rows: Row[], id: string | null) {
  return rows.findIndex((row) => row.id === id);
}

function restoreIndexFor(rows: Row[], id: string | null) {
  return Math.max(0, indexFor(rows, id));
}

export default function App() {
  const [mode, setMode] = useState<Mode | null>(null);
  const [savedId, setSavedId] = useState<string | null>(null);
  const [removedId, setRemovedId] = useState<string | null>(null);
  const [prepend, setPrepend] = useState(false);
  const [marked, setMarked] = useState<Record<string, boolean>>({});
  const [jumpError, setJumpError] = useState(false);
  const flashRef = useRef<FlashListRef<Row>>(null);
  const legendRef = useRef<LegendListRef>(null);

  const rows = useMemo(() => {
    const remaining = originalRows.filter((row) => row.id !== removedId);
    return prepend ? [insertedRow, ...remaining] : remaining;
  }, [prepend, removedId]);
  const initialScrollIndex = restoreIndexFor(rows, savedId);
  const jumpIndex = indexFor(rows, anchorId);

  async function jumpToTicket() {
    if (mode === null || jumpIndex < 0) return;
    const list = mode === "flash" ? flashRef.current : legendRef.current;
    setJumpError(false);
    try {
      await list?.scrollToIndex({ index: jumpIndex, animated: false, viewPosition: 0 });
    } catch {
      setJumpError(true);
    }
  }

  if (mode === null) {
    return (
      <View style={{ flex: 1 }}>
        <Text>Saved row: {savedId ?? "none"}</Text>
        <Button title="Prepend a row" onPress={() => setPrepend(true)} />
        <Button title="Remove saved row" disabled={!savedId}
          onPress={() => setRemovedId(savedId)} />
        <Button title="Open FlashList" onPress={() => setMode("flash")} />
        <Button title="Open Legend List" onPress={() => setMode("legend")} />
        <Button title="Open Legend List with recycling"
          onPress={() => setMode("legend-recycling")} />
      </View>
    );
  }

  const shared = {
    data: rows,
    initialScrollIndex,
    keyExtractor,
    getItemType,
    extraData: marked,
    keyboardShouldPersistTaps: "handled" as const,
    keyboardDismissMode: "on-drag" as const,
    renderItem: ({ item }: { item: Row }) => (
      <View testID={item.id} style={{ padding: 12, borderBottomWidth: 1 }}>
        <Text>{item.id}</Text>
        {item.kind === "note" && (
          <Text>{"Customer replied.\nCheck the delivery address.\nWait for confirmation."}</Text>
        )}
        <Button testID={`mark-${item.id}`} title={marked[item.id] ? "Unmark" : "Mark"}
          onPress={() => setMarked((current) => ({ ...current, [item.id]: !current[item.id] }))} />
        <Button testID={`save-${item.id}`} title="Save and close"
          onPress={() => {
            Keyboard.dismiss();
            setSavedId(item.id);
            setJumpError(false);
            setMode(null);
          }} />
      </View>
    ),
  };

  return (
    <View style={{ flex: 1 }}>
      <TextInput testID="keyboard-test" placeholder="Keyboard test"
        style={{ borderWidth: 1, padding: 8 }} />
      <Button title="Jump to ticket-160" disabled={jumpIndex < 0}
        onPress={() => { void jumpToTicket(); }} />
      {jumpError && <Text>Jump failed</Text>}
      <View style={{ flex: 1 }}>
        {mode === "flash" ? (
          <FlashList ref={flashRef} {...shared} />
        ) : (
          <LegendList ref={legendRef} {...shared} recycleItems={mode === "legend-recycling"} />
        )}
      </View>
    </View>
  );
}
```

## Restore a record after the list remounts

<!-- pipeline:claim c006 -->

Save a stable row ID at the point your app leaves the screen. The fixture saves the row the tester presses. In an inbox that restores after a navigation Back action, use the currently visible record your app considers the anchor. Keep that ID with the filter or feed identity in navigation state or a screen store. When the screen mounts again, resolve the ID after loading the relevant data, then pass the index as `initialScrollIndex`. If the row was deleted or filtered out, choose a fallback. The fixture starts at the top. An app could choose the next available record if it can recover its order.

Saving the original index only works while the order stays unchanged. Saving a raw offset assumes the sizes above the anchor are unchanged, too. If the product needs the same position inside a partially visible row, record the relative offset as well. The current FlashList API accepts `initialScrollIndexParams.viewOffset`. Legend List accepts `initialScrollIndex={{ index, viewOffset }}`. Check the offset with real content, sticky headers and current insets. Near the end of a list, the viewport can reach the content limit before the target row reaches the top. For a list that stays mounted, use the ref's `scrollToIndex` with the resolved index. Both pinned versions return a promise. Await it before running logic that depends on the command finishing. [FlashList usage](https://shopify.github.io/flash-list/docs/usage/) · [Legend List API](https://legendapp.com/open-source/list/v3/api/)

Test live prepends separately from reopening. FlashList v2 enables `maintainVisibleContentPosition` by default. Legend List v3 defaults to size-change stabilization with data-change anchoring off. To keep the visible content anchored during a live prepend, try `maintainVisibleContentPosition={{ data: true, size: true }}` on Legend List and check insertions and reorders while the list remains mounted. The fixture applies the prepend while the list is closed, so this setting cannot restore its saved row. [Legend List migration to v3](https://legendapp.com/open-source/list/v3/migration/)

## Check taps and keyboard insets on device

<!-- pipeline:claim c007 -->

The fixture uses React Native's `keyboardShouldPersistTaps="handled"` so a child that handles the tap can act while the keyboard stays up. `keyboardDismissMode="on-drag"` requests dismissal when dragging starts. Use those props on the list that owns the gesture. In an app with a sheet or enclosing scroll view, repeat the checks there because the parent can handle the gesture first. Verify that the focused field and the row actions stay reachable with the keyboard open. [React Native ScrollView](https://reactnative.dev/docs/scrollview)

For a floating chat composer, Legend List also exposes `KeyboardAwareLegendList` and `useKeyboardChatComposerInset` from `@legendapp/list/keyboard`. That entry point integrates with React Native Keyboard Controller and Reanimated. Treat it as a separate change to the screen layout. Check which layer accounts for the keyboard inset so that the app does not apply it twice. The example keeps a regular input outside the list. [Legend List guides](https://legendapp.com/open-source/list/v3/guides/)

| Check | Reproduce it on iOS and Android | Expected result |
| --- | --- | --- |
| Sizing and jump | Open from a fresh launch. Drag past the first note and adjacent ticket, then press **Jump to ticket-160**. | Both row types show all actions. The jump lands on `ticket-160` near the top and stays there when layout settles. Watch for clipping, overlaps or a visible jump during landing. |
| Recycled state | From a fresh launch, mark `ticket-0`, jump to `ticket-160`, scroll a few screens and return to the start. Repeat with Legend List recycling enabled. | Rows you did not mark still show **Mark**. `ticket-0` still shows **Unmark**. |
| Remount with changed data | Jump to `ticket-160`, press **Save and close** on that row, prepend and reopen. Close again from the same row, remove it and reopen. | The first reopen lands on `ticket-160` despite the shifted index. After removal, `new-ticket` is at the top and the jump button is disabled. |
| Keyboard taps and drag | Focus **Keyboard test** so the software keyboard is visible. Tap a visible **Mark** button, then drag the list. On Android also dismiss using Back with the keyboard open. | The first tap changes only the tapped row and keeps the keyboard up. The drag dismisses it. Android Back dismisses the keyboard and keeps the screen open. The list uses the recovered space and its actions remain reachable. |

Run the table first with FlashList, then with Legend List and finally with recycling enabled. Use the same device, font scaling and build configuration. Start each run with a fresh screen state. In your real screen, repeat restoration after slow data arrival and with your actual navigator, keyboard avoidance or sheet configuration. If the input or a row action disappears under the keyboard, capture the host configuration and the failing interaction before tuning list settings.

## Decide when to switch the screen

If both Legend List modes pass, use the one that meets your device requirements. If enabling recycling leaks state, leave it off while you move durable state out of the cells. Keep FlashList available for this screen until the selected Legend List mode passes the full device checklist. For a performance-motivated migration, replay the same scroll and far-jump sequence on the same release build and device. Record your app's frame timing and memory separately from the correctness checks. The fixture supplies a repeatable workload for that comparison.

## Methodology

<!-- pipeline:source s001 -->
<!-- pipeline:source s002 -->
<!-- pipeline:source s003 -->
<!-- pipeline:source s004 -->
<!-- pipeline:source s005 -->
<!-- pipeline:source s006 -->
<!-- pipeline:source s007 -->
<!-- pipeline:source s008 -->
<!-- pipeline:source s009 -->
<!-- pipeline:source s010 -->
<!-- pipeline:source s011 -->
<!-- pipeline:source s012 -->
<!-- pipeline:source s013 -->
<!-- pipeline:source s014 -->
<!-- pipeline:source s015 -->
<!-- pipeline:source s016 -->
<!-- pipeline:source s017 -->
<!-- pipeline:source s018 -->

The fixture passed TypeScript checking against the published React Native, FlashList and Legend List declarations. Local assertions checked the saved ID after an insertion and the fallback after deletion using the fixture's lookup logic. The acceptance table describes expected behavior for a native run. It has no device, simulator, browser, keyboard or frame timing measurements. [FlashList release](https://github.com/Shopify/flash-list/releases/tag/v2.3.3) · [Legend List release](https://github.com/LegendApp/legend-list/releases/tag/v3.9.2) · [React Native release](https://github.com/react/react-native/releases/tag/v0.88.1)

## Related guides

- Use the [FlashList, FlatList and Legend List comparison](/guides/flashlist-vs-flatlist-vs-legendlist-react-native-lists-2026) if you are still choosing a list library.
- Turn the acceptance steps into a device test with the [React Native E2E testing guide](/guides/detox-vs-maestro-vs-appium-react-native-e2e-testing-2026).
- If your list lives in a sheet, check the container setup in the [React Native bottom sheet guide](/guides/gorhom-bottom-sheet-vs-expo-bottom-sheet-vs-rnsbs-2026).
