Lynx ui feed list

From lynx-family/lynx-ui · View interactive version

Lynx ui feed list is an AI agent skill from the GitHub repository lynx-family/lynx-ui. `FeedList` is a high-performance feed stream list component, built upon `List`. It encapsulates common feed scenarios such as **pull-to-refresh** and **load more**, allowing developers to quickly buil

How to use this skill

Skill file

lynx-ui-feed-list SKILL

FeedList is a high-performance feed stream list component, built upon List. It encapsulates common feed scenarios such as pull-to-refresh and load more, allowing developers to quickly build feed list pages.

Note: Use FeedList only when you need pull-to-refresh and load-more behaviors. For regular virtual lists without these features, prefer using List directly.

1. Core Capabilities

2. AI Coding Guide

Minimal Usable Example

When using FeedList, you MUST provide listId and listType, and use <list-item> as the direct child. To enable pull-to-refresh and load more, you also need to configure the corresponding props and get the instance via ref to control the state.

import { useRef } from '@lynx-js/react'
import { FeedList, FeedListRef } from '@lynx-js/lynx-ui'

function BasicFeedList() {
  const feedListRef = useRef<FeedListRef>(null)
  const items = Array.from({ length: 20 }, (_, i) => `Item ${i}`)

  const handleRefresh = () => {
    console.log('Refreshing...')
    setTimeout(() => {
      feedListRef.current?.finishRefresh()
    }, 2000)
  }

  const handleLoadMore = () => {
    console.log('Loading more...')
    // After loading, you might need to call feedListRef.current?.changeHasMoreStatus(false);
  }

  return (
    <FeedList
      ref={feedListRef}
      listId='my-feed-list'
      listType='single'
      refreshOptions={{
        enableRefresh: true,
        mode: 'native',
        headerContent: <text>Refreshing…</text>,
        onStartRefresh: handleRefresh,
      }}
      onScrollToLower={handleLoadMore}
      style={{ width: '100%', height: '500px' }}
    >
      {items.map(item => (
        <list-item item-key={item} key={item}>
          <view style={{ height: '60px' }}>{item}</view>
        </list-item>
      ))}
    </FeedList>
  )
}

Recommended Prompt Formula

Scenario Description + Layout Configuration + Refresh and Load More Logic + Custom UI

Example Prompt:

3. Use Cases & Best Practices

Basic Feed Stream List

A list with pull-to-refresh and load more functionality.

import { useRef, useState } from '@lynx-js/react';
import { FeedList, FeedListRef } from '@lynx-js/lynx-ui';

function FullFeaturedFeedList() {
  const listRef = useRef<FeedListRef>(null);
  const [items, setItems] = useState([...]);
  const [hasMore, setHasMore] = useState(true);

  const onRefresh = async () => {
    const newData = await fetchNewData();
    setItems(newData);
    listRef.current?.finishRefresh();
    setHasMore(true); // Reset hasMore status on refresh
    listRef.current?.changeHasMoreStatus(true);
  };

  const onLoadMore = async () => {
    if (!hasMore) return;
    const moreData = await fetchMoreData();
    if (moreData.length > 0) {
      setItems([...items, ...moreData]);
    } else {
      setHasMore(false);
      listRef.current?.changeHasMoreStatus(false);
    }
  };

  return (
    <FeedList
      ref={listRef}
      listId="feed"
      listType="single"
      refreshOptions={{ onRefresh }}
      onScrollToLower={onLoadMore}
      loadMoreFooter={<text>Loading...</text>}
      noMoreDataFooter={<text>-- End --</text>}
    >
      {/* ... list-items ... */}
    </FeedList>
  );
}

Example Path: apps/examples/src/FeedList/Basic/index.tsx

Grid Layout Feed

Combine listType: 'flow' to create a feed in a grid layout.

<FeedList
  listId='grid-feed'
  listType='flow'
  spanCount={2}
  {...otherProps}
>
  {/* ... */}
</FeedList>

Example Path: apps/examples/src/FeedList/Grid/index.tsx

Managing Footer State

FeedList displays two footer variants:

Footers are controlled exclusively via ref.current.changeHasMoreStatus(hasMore). They are not linked to refresh status or diff results.

import { useRef, useState } from '@lynx-js/react'
import { FeedList, FeedListRef } from '@lynx-js/lynx-ui'

function FooterStateExample() {
  const listRef = useRef<FeedListRef>(null)
  const [hasMore, setHasMore] = useState(true)

  const onScrollToLower = () => {
    // fetch more...
    const more = await fetchMore()
    if (more.length === 0) {
      setHasMore(false)
      listRef.current?.changeHasMoreStatus(false) // switch to noMoreDataFooter
    }
  }

  const onRefresh = async () => {
    // refresh resets footer state if needed
    setHasMore(true)
    listRef.current?.changeHasMoreStatus(true) // back to loadMoreFooter
    listRef.current?.finishRefresh()
  }

  return (
    <FeedList
      ref={listRef}
      listId='feed'
      listType='single'
      refreshOptions={{ onRefresh }}
      onScrollToLower={onScrollToLower}
      loadMoreFooter={<text>Loading…</text>}
      noMoreDataFooter={<text>-- End --</text>}
    >
      {/* ... list-items ... */}
    </FeedList>
  )
}

Selecting the Refresh Implementation

FeedList uses useRefreshAndBounce by default. Set refreshOptions.mode to 'native' when a vertical list should use the platform-native <refresh> element instead. The startRefresh() and finishRefresh() ref methods and the callbacks in refreshOptions work in both modes.

<FeedList
  ref={listRef}
  listId='native-refresh-feed'
  listType='single'
  scrollOrientation='vertical'
  refreshOptions={{
    enableRefresh: true,
    mode: 'native',
    headerContent: <RefreshHeader />,
    onStartRefresh,
  }}
>
  {/* ... list-items ... */}
</FeedList>

Do not set mode: 'native' for horizontal lists. Keep the default hook-based mode when custom bounceableOptions must coordinate upper-edge bouncing with refresh gestures.

4. FAQ

Q: After triggering onRefresh, the refresh header persists. What should I do?

A: FeedList does not automatically end the refresh animation. Call ref.current.finishRefresh() after your data request completes; otherwise, the refresh header remains visible.

Q: After loading all data, the load more footer is still displayed. How do I stop it?

A: Call ref.current.changeHasMoreStatus(false) to indicate there is no more data, and display noMoreDataFooter instead of loadMoreFooter.

Q: When should I use FeedList vs List?

A: Use FeedList only when you need pull-to-refresh and load-more behaviors. For regular virtual lists without these features, prefer using List directly.

5. Sub components

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.