Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions docs/useList.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: "useList"

The `useList` hook allows to create a `ListContext` based on local data. `useList` creates callbacks for sorting, paginating, filtering, and selecting records from an array.

Thanks to it, you can display your data inside a [`<Datagrid>`](./Datagrid.md), a [`<SimpleList>`](./SimpleList.md) or an [`<EditableDatagrid>`](./EditableDatagrid.md).
Thanks to it, you can display your data inside a [`<Datagrid>`](./Datagrid.md), a [`<SimpleList>`](./SimpleList.md) or an [`<EditableDatagrid>`](./EditableDatagrid.md).

## Usage

Expand All @@ -31,7 +31,7 @@ const MyComponent = () => {
const listContext = useList({ data });
return (
<ListContextProvider value={listContext}>
<Datagrid>
<Datagrid resource="actors">
<TextField source="id" />
<TextField source="name" />
</Datagrid>
Expand All @@ -53,14 +53,15 @@ const MyComponent = () => {
const listContext = useList({ data, isPending });
return (
<ListContextProvider value={listContext}>
<Datagrid>
<Datagrid resource="posts">
<TextField source="id" />
<TextField source="name" />
</Datagrid>
</ListContextProvider>
);
};
```

## Parameters

`useList` expects an object with the following keys:
Expand All @@ -69,7 +70,7 @@ const MyComponent = () => {
* [`filter`](#filter)
* [`filterCallback`](#filtercallback)
* [`isFetching`](#isfetching)
* [`isPending`](#isPending)
* [`isPending`](#ispending)
* [`page`](#page)
* [`perPage`](#perpage)
* [`sort`](#sort)
Expand Down Expand Up @@ -153,7 +154,7 @@ const MyComponent = () => {
const listContext = useList({ data, isFetching });
return (
<ListContextProvider value={listContext}>
<Datagrid>
<Datagrid resource="posts">
<TextField source="id" />
<TextField source="name" />
</Datagrid>
Expand Down Expand Up @@ -183,7 +184,7 @@ const MyComponent = () => {
const listContext = useList({ data, isPending });
return (
<ListContextProvider value={listContext}>
<Datagrid>
<Datagrid resource="posts">
<TextField source="id" />
<TextField source="name" />
</Datagrid>
Expand Down Expand Up @@ -256,7 +257,7 @@ const { data } = useList({

## Return Value

`useList` returns an object with keys matching the shape of the `ListContext`:
`useList` returns an object with keys matching the shape of the `ListContext`:

```jsx
const {
Expand Down
Loading