---
name: webf-infinite-scrolling
description: Create high-performance infinite scrolling lists with pull-to-refresh and load-more capabilities using WebFListView. Use when building feed-style UIs, product catalogs, chat messages, or any scrollable list that needs optimal performance with large datasets.
---
# WebF Infinite Scrolling
> **Note**: WebF development is nearly identical to web development - you use the same tools (Vite, npm, Vitest), same frameworks (React, Vue, Svelte), and same deployment services (Vercel, Netlify). This skill covers **performance optimization for scrolling lists** - a WebF-specific pattern that provides native-level performance automatically.
Build high-performance infinite scrolling lists with Flutter-optimized rendering. WebF's `WebFListView` component automatically handles performance optimizations at the Flutter level, providing smooth 60fps scrolling even with thousands of items.
## Why Use WebFListView?
In browsers, long scrolling lists can cause performance issues:
- DOM nodes accumulate (memory consumption)
- Re-renders affect all items (slow updates)
- Intersection observers needed for virtualization
- Complex state management for infinite loading
**WebF's solution**: `WebFListView` delegates rendering to Flutter's optimized ListView widget, which:
- ✅ Automatically virtualizes (recycles) views
- ✅ Maintains 60fps scrolling with thousands of items
- ✅ Provides native pull-to-refresh and load-more
- ✅ Zero configuration - optimization happens automatically
## Critical Structure Requirement
**⚠️ IMPORTANT**: For Flutter optimization to work, each list item must be a **direct child** of `WebFListView`:
### ✅ CORRECT: Direct Children
```jsx
Item 1
Item 2
Item 3
{/* Each item is a direct child */}
```
### ❌ WRONG: Wrapped in Container
```jsx
{/* DON'T wrap items in a container div */}
Item 1
Item 2
Item 3
```
**Why this matters**: Flutter's ListView requires direct children to perform view recycling. If items are wrapped in a container, Flutter sees only one child (the container) and cannot optimize individual items.
## React Setup
### Installation
```bash
npm install @openwebf/react-core-ui
```
### Basic Scrolling List
```tsx
import { WebFListView } from '@openwebf/react-core-ui';
function ProductList() {
const products = [
{ id: 1, name: 'Product 1', price: 19.99 },
{ id: 2, name: 'Product 2', price: 29.99 },
{ id: 3, name: 'Product 3', price: 39.99 },
// ... hundreds or thousands of items
];
return (
{products.map(product => (
// ✅ Each item is a direct child
{product.name}
${product.price}
))}
);
}
```
### Infinite Scrolling with Load More
```tsx
import { WebFListView, WebFListViewElement } from '@openwebf/react-core-ui';
import { useRef, useState } from 'react';
function InfiniteList() {
const listRef = useRef(null);
const [items, setItems] = useState([1, 2, 3, 4, 5]);
const [page, setPage] = useState(1);
const handleLoadMore = async () => {
try {
// Simulate API call
await new Promise(resolve => setTimeout(resolve, 1000));
// Fetch next page
const newItems = Array.from(
{ length: 5 },
(_, i) => items.length + i + 1
);
setItems(prev => [...prev, ...newItems]);
setPage(prev => prev + 1);
// Check if there's more data
const hasMore = page < 10; // Example: 10 pages max
// Notify WebFListView that loading finished
listRef.current?.finishLoad(hasMore ? 'success' : 'noMore');
} catch (error) {
// Notify failure
listRef.current?.finishLoad('fail');
}
};
return (
{items.map(item => (