Skip to content

Commit

Permalink
[Doc] Add video tutorial to ReferenceManyCount doc
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Mar 13, 2024
1 parent dbeea1d commit 6cb5dd6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/ReferenceManyCount.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: "The ReferenceManyCount Component"

When you need to render the number of records related to another record via a one-to-many relationship (e.g. the number of comments related to a post), use the `<ReferenceManyCount>` component. It calls `dataProvider.getManyReference()` with the `pagination` parameter set to retrieve no data - only the total number of records.

![ReferenceManyCount](./img/reference_many_count.webp)
<iframe src="https://www.youtube-nocookie.com/embed/XCucarroK8o" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen style="aspect-ratio: 16 / 9;width:100%;margin-bottom:1em;"></iframe>

## Usage

Expand All @@ -16,6 +16,8 @@ Use `<ReferenceManyCount>` as a regular Field in a `<Datagrid>` or `<SimpleShowL
- `reference` is the name of the related resource to fetch (e.g. `comments`)
- `target` is the name of the field in the related resource that points to the current resource (e.g. `post_id`)

For instance, to display the number of comments related to a post in a List view:

```jsx
import {
ChipField,
Expand Down Expand Up @@ -56,6 +58,8 @@ export const PostList = () => (
)
```

![ReferenceManyCount](./img/reference_many_count.webp)

**Tip**: If you need to count all the records of a given resource, use [the `<Count>` component](./Count.md) instead.

## Props
Expand Down

0 comments on commit 6cb5dd6

Please sign in to comment.