Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Fix <Datagrid> standalone usage misses required resource prop #9991

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
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
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
Loading