Skip to content

Commit

Permalink
Merge pull request #9991 from marmelab/fix-datagrid-standalone-doc
Browse files Browse the repository at this point in the history
[Doc] Fix `<Datagrid>` standalone usage misses required `resource` prop
  • Loading branch information
djhi authored Jul 10, 2024
2 parents 42f982b + 0b2f9d3 commit 1af6616
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/Datagrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ const MyCustomList = () => {

return (
<Datagrid
resource="books"
data={data}
total={total}
isPending={isPending}
Expand Down
30 changes: 30 additions & 0 deletions docs/Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ React-admin v5 mostly focuses on removing deprecated features and upgrading depe
- [`<List hasCreate>` Is No Longer Supported](#list-hascreate-is-no-longer-supported)
- [`<Datagrid rowClick>` is no longer false by default](#datagrid-rowclick-is-no-longer-false-by-default)
- [`<Datagrid expand>` Components No Longer Receive Any Props](#datagrid-expand-components-no-longer-receive-any-props)
- [`<Datagrid>` In Standalone Requires a `resource` Prop](#datagrid-in-standalone-requires-a-resource-prop)
- [setFilters Is No Longer Debounced By Default](#setfilters-is-no-longer-debounced-by-default)
- [Updates to bulkActionButtons Syntax](#updates-to-bulkactionbuttons-syntax)
- [`<PaginationLimit>` Component Was Removed](#paginationlimit-component-was-removed)
Expand Down Expand Up @@ -769,6 +770,35 @@ If you used these props in your expand components, you'll have to use the `useRe
}
```

### `<Datagrid>` In Standalone Requires a `resource` Prop

When using `<Datagrid>` outside of a `<List>` component, you now need to pass a `resource` prop:

```diff
const sort = { field: 'id', order: 'DESC' };

const MyCustomList = () => {
const { data, total, isPending } = useGetList('books', {
pagination: { page: 1, perPage: 10 },
sort,
});

return (
<Datagrid
+ resource="books"
data={data}
total={total}
isPending={isPending}
sort={sort}
bulkActionButtons={false}
>
<TextField source="id" />
<TextField source="title" />
</Datagrid>
);
};
```

### `setFilters` Is No Longer Debounced By Default

If you're using the `useListContext` hook to filter a list, you might have used the `setFilters` function to update the filters. In react-admin v5, the `setFilters` function is no longer debounced by default. If you want to debounce the filters, you'll have to pass `true` as the third argument:
Expand Down

0 comments on commit 1af6616

Please sign in to comment.