Refresh and loading
Add pull-to-refresh and show a loading state over the grid.
Basic usage
refresh-loading.tsx
import { useState } from 'react';
import { ActivityIndicator } from 'react-native';
import { DataGrid } from 'expo-flash-datagrid';
import { userColumns, users, type User } from './data';
export function RefreshableScreen() {
const [refreshing, setRefreshing] = useState(false);
const refresh = () => {
setRefreshing(true);
setTimeout(() => setRefreshing(false), 700);
};
return (
<DataGrid<User>
mode="client"
rows={users}
columns={userColumns}
refreshing={refreshing}
onRefresh={refresh}
loadingOverlay={<ActivityIndicator size="large" />}
style={{ flex: 1 }}
/>
);
}
Options
| Prop | Type | Default | Description |
|---|---|---|---|
loading | boolean | false | Shows the overlay and suppresses the empty state. |
loadingOverlay | ReactNode | Built-in spinner | Replaces the overlay's content. |
refreshing | boolean | false | Pull-to-refresh indicator. Only used with onRefresh. |
onRefresh | () => void | None | Enables pull-to-refresh. |
Client vs server
Both props are display-only, and work the same in both modes. In server mode you typically tie loading to the request.