Skip to content

Commit 005331a

Browse files
authored
Merge pull request #10491 from marmelab/doc-fix-uselist
[Doc] Fix useList usage contains incorrect code snippet
2 parents e73c8d8 + 24c8891 commit 005331a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

docs/useList.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: "useList"
77

88
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.
99

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

1212
## Usage
1313

@@ -31,7 +31,7 @@ const MyComponent = () => {
3131
const listContext = useList({ data });
3232
return (
3333
<ListContextProvider value={listContext}>
34-
<Datagrid>
34+
<Datagrid resource="actors">
3535
<TextField source="id" />
3636
<TextField source="name" />
3737
</Datagrid>
@@ -53,14 +53,15 @@ const MyComponent = () => {
5353
const listContext = useList({ data, isPending });
5454
return (
5555
<ListContextProvider value={listContext}>
56-
<Datagrid>
56+
<Datagrid resource="posts">
5757
<TextField source="id" />
5858
<TextField source="name" />
5959
</Datagrid>
6060
</ListContextProvider>
6161
);
6262
};
6363
```
64+
6465
## Parameters
6566

6667
`useList` expects an object with the following keys:
@@ -69,7 +70,7 @@ const MyComponent = () => {
6970
* [`filter`](#filter)
7071
* [`filterCallback`](#filtercallback)
7172
* [`isFetching`](#isfetching)
72-
* [`isPending`](#isPending)
73+
* [`isPending`](#ispending)
7374
* [`page`](#page)
7475
* [`perPage`](#perpage)
7576
* [`sort`](#sort)
@@ -153,7 +154,7 @@ const MyComponent = () => {
153154
const listContext = useList({ data, isFetching });
154155
return (
155156
<ListContextProvider value={listContext}>
156-
<Datagrid>
157+
<Datagrid resource="posts">
157158
<TextField source="id" />
158159
<TextField source="name" />
159160
</Datagrid>
@@ -183,7 +184,7 @@ const MyComponent = () => {
183184
const listContext = useList({ data, isPending });
184185
return (
185186
<ListContextProvider value={listContext}>
186-
<Datagrid>
187+
<Datagrid resource="posts">
187188
<TextField source="id" />
188189
<TextField source="name" />
189190
</Datagrid>
@@ -256,7 +257,7 @@ const { data } = useList({
256257

257258
## Return Value
258259

259-
`useList` returns an object with keys matching the shape of the `ListContext`:
260+
`useList` returns an object with keys matching the shape of the `ListContext`:
260261

261262
```jsx
262263
const {

0 commit comments

Comments
 (0)