MCPcopy
hub / github.com/LegendApp/legend-list

github.com/LegendApp/legend-list @v3.3.0 sqlite

repository ↗ · DeepWiki ↗ · release v3.3.0 ↗
1,426 symbols 4,249 edges 518 files 0 documented · 0%
README

Legend List

Legend List is a high-performance list component for React Native, written purely in Typescript with no native dependencies. It is a drop-in replacement for FlatList and FlashList with better performance, especially when handling dynamically sized items.


🤔 Why Legend List?

  • Performance: Designed from the ground up and heavily optimized for performance, it is faster than FlatList and other list libraries in most scenarios.
  • Dynamic Item Sizes: Natively supports items with varying heights without performance hits.
  • Drop-in Replacement: API compatibility with FlatList and FlashList for easier migration.
  • 100% JS: No native module linking required, ensuring easy integration and compatibility across platforms.
  • Lightweight: Our goal is to keep LegendList as small of a dependency as possible. For more advanced use cases, we plan on supporting optional plugins. This ensures that we keep the package size as small as possible.
  • Bidirectional infinite lists: Supports infinite scrolling in both directions with no flashes or scroll jumping
  • Chat UIs without inverted: Chat UIs can align their content to the bottom and maintain scroll at end, so that the list doesn't need to be inverted, which causes weird behavior (in animations, etc...)

For more information, listen to the Legend List episode of the React Native Radio Podcast and the livestream with Expo.


✨ Additional Features

Beyond standard FlatList capabilities:

  • recycleItems: (boolean) Toggles item component recycling.
    • true: Reuses item components for optimal performance. Be cautious if your item components contain local state, as it might be reused unexpectedly.
    • false (default): Creates new item components every time. Less performant but safer if items have complex internal state.
  • maintainScrollAtEnd: Keeps the list pinned to the tail when the user is already near the end (within maintainScrollAtEndThreshold * screen height). Pass true for all triggers, or { animated?: boolean, on?: { dataChange?: boolean, layout?: boolean, itemLayout?: boolean } }; if on is omitted, the object form also enables all triggers.
  • maintainVisibleContentPosition: Keeps visible content steady during size/layout changes while scrolling up or when items resize above the viewport (default). Pass true or { data: true } to also anchor during data updates; pass false to disable; pass { size: false } to opt out of scroll-time stabilization.
  • alignItemsAtEnd: (boolean) Useful for chat UIs, content smaller than the View will be aligned to the bottom of the list.

📚 Documentation

For comprehensive documentation, guides, and the full API reference, please visit:

➡️ Legend List Documentation Site


💻 Usage

Installation

# Using Bun
bun add @legendapp/list

# Using npm
npm install @legendapp/list

# Using Yarn
yarn add @legendapp/list

Typed Imports

  • React Native: @legendapp/list/react-native
  • React: @legendapp/list/react

Example

import React, { useRef } from "react"
import { View, Image, Text, StyleSheet } from "react-native"
import { LegendList, LegendListRef, LegendListRenderItemProps } from "@legendapp/list/react-native"

// Define the type for your data items
interface UserData {
    id: string;
    name: string;
    photoUri: string;
}

const LegendListExample = () => {
    // Optional: Ref for accessing list methods (e.g., scrollTo)
    const listRef = useRef<LegendListRef | null>(null)

    const data = []

    const renderItem = ({ item }: LegendListRenderItemProps<UserData>) => {
        return (
            <View>
                <Image source={{ uri: item.photoUri }} />
                <Text>{item.name}</Text>
            </View>
        )
    }

    return (
        <LegendList
            // Required Props
            data={data}
            renderItem={renderItem}

            // Recommended props (Improves performance)
            keyExtractor={(item) => item.id}
            recycleItems={true}

            // Recommended if data can change
            maintainVisibleContentPosition

            ref={listRef}
        />
    )
}

export default LegendListExample


How to Build

  1. bun i
  2. bun run build will build the package to the dist folder.

Running the Example

  1. cd example
  2. bun i
  3. bun run ios

PRs gladly accepted!

There's not a ton of code so hopefully it's easy to contribute. If you want to add a missing feature or fix a bug please post an issue to see if development is already in progress so we can make sure to not duplicate work 😀.

Upcoming Roadmap

  • [] Column spans
  • [] overrideItemLayout
  • [] Sticky headers
  • [] Masonry layout
  • [] getItemType
  • [] React DOM implementation

Community

Join us on Discord to get involved with the Legend community.

👩‍⚖️ License

MIT

Extension points exported contracts — how you extend this code

CardsProps (Interface)
(no doc)
example/components/Cards.tsx
CardsProps (Interface)
(no doc)
example/screens/fixtures/accurate-scrollto-huge.tsx
Playlist (Interface)
(no doc)
example/api/index.ts
CardItem (Interface)
(no doc)
example/hooks/filter-data-provider.tsx
Register (Interface)
(no doc)
example-web/src/router.tsx
Insets (Interface)
(no doc)
src/types.base.ts
ScrollEventTargetLike (Interface)
(no doc)
src/types.internal.ts
AnchoredEndSpaceConfig (Interface)
(no doc)
src/types.web.ts

Core symbols most depended-on inside this repo

set$
called by 126
src/state/state.tsx
peek$
called by 123
src/state/state.tsx
calculateItemsInView
called by 82
src/core/calculateItemsInView.ts
getId
called by 76
src/utils/getId.ts
prepareMVCP
called by 69
src/core/mvcp.ts
setDidLayout
called by 56
src/utils/setDidLayout.ts
requestAdjust
called by 54
src/utils/requestAdjust.ts
onScroll
called by 54
src/core/onScroll.ts

Shape

Function 1,217
Interface 122
Method 67
Class 20

Languages

TypeScript100%

Modules by API surface

src/core/bootstrapInitialScroll.ts34 symbols
src/types.base.ts29 symbols
src/types.internal.ts20 symbols
src/components/ListComponentScrollView.tsx20 symbols
prebuild.ts20 symbols
__tests__/components/LegendList.initialScroll.integration.test.tsx19 symbols
__tests__/components/LegendList.bootstrapInitialScroll.test.tsx19 symbols
__tests__/components/LegendList.bootstrapInitialScroll.oldarch.cases.tsx19 symbols
__tests__/components/LegendList.liveUpdates.integration.test.tsx18 symbols
__tests__/components/LegendList.dataRefresh.integration.test.tsx17 symbols
src/core/initialScrollSession.ts16 symbols
src/core/checkFinishedScroll.ts15 symbols

Dependencies from manifests, versioned

@babel/core7.27.4 · 1×
@biomejs/biome2.1.2 · 1×
@expo/vector-icons15.0.3 · 1×
@legendapp/motion2.4.0 · 1×
@legendapp/state3.0.0-beta.19 · 1×
@react-native-community/clilatest · 1×
@react-navigation/bottom-tabs7.3.10 · 1×
@react-navigation/native7.1.6 · 1×
@tailwindcss/vite4.1.14 · 1×
@tanstack/react-virtual3.13.12 · 1×

For agents

$ claude mcp add legend-list \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact