Skip to content

Commit 7836911

Browse files
committed
Update <ListBase> in headless documentation
1 parent dc7a05a commit 7836911

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs_headless/src/content/docs/ListBase.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ The `<ListBase>` component accepts the following props:
8686
| `debounce` | Optional | `number` | `500` | The debounce delay in milliseconds to apply when users change the sort or filter parameters. |
8787
| `disableAuthentication` | Optional | `boolean` | `false` | Set to `true` to disable the authentication check. |
8888
| `disableSyncWithLocation` | Optional | `boolean` | `false` | Set to `true` to disable the synchronization of the list parameters with the URL. |
89+
| `empty` | Optional | `ReactNode` | - | The component to display when the list is empty. |
8990
| `error` | Optional | `ReactNode` | - | The component to render when failing to load the list of records. |
9091
| `exporter` | Optional | `function` | - | The function to call to export the list. |
9192
| `filter` | Optional | `object` | - | The permanent filter values. |
@@ -210,6 +211,34 @@ const Dashboard = () => (
210211
);
211212
```
212213
214+
## `empty`
215+
216+
By default, `<ListBase>` renders the children when there is no result and no active filter. If you want for instance to invite users to create the first record, you can render a custom component via the `empty` prop:
217+
218+
{% raw %}
219+
```jsx
220+
import { ListBase } from 'ra-core';
221+
import { Link } from 'react-router';
222+
223+
const Empty = () => (
224+
<div>
225+
<h4>
226+
No product available
227+
</h4>
228+
<Link to="/products/create">Create the first product</Link>
229+
</div>
230+
);
231+
232+
const ProductList = () => (
233+
<ListBase empty={<Empty />}>
234+
...
235+
</ListBase>
236+
);
237+
```
238+
{% endraw %}
239+
240+
The `empty` component can call the [`useListContext()`](./useListContext.md) hook to receive the same props as the `ListBase` child component.
241+
213242
## `error`
214243
215244
By default, `<ListBase>` renders the children when an error happens while loading the list of records. You can render an error component via the `error` prop:

0 commit comments

Comments
 (0)