Skip to main content

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​

PropTypeDefaultDescription
loadingbooleanfalseShows the overlay and suppresses the empty state.
loadingOverlayReactNodeBuilt-in spinnerReplaces the overlay's content.
refreshingbooleanfalsePull-to-refresh indicator. Only used with onRefresh.
onRefresh() => voidNoneEnables 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.