Skip to content

Commit

Permalink
[Doc] Add link to custom fields video tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Feb 28, 2024
1 parent 9ce6c30 commit 601a0d6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/Fields.md
Expand Up @@ -457,7 +457,9 @@ const BookList = () => (

If you don't find what you need in the list of available Fields, you can write your own Field component.

It must be a regular React component, accepting a `source` attribute and retrieving the `record` from the `RecordContext` with the `useRecordContext` hook. React-admin will set the `record` in this context based on the API response data at render time. The field component only needs to find the `source` in the `record` and display it.
<iframe src="https://www.youtube-nocookie.com/embed/tTNDAssRJhU" 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>

A custom field must be a regular React component retrieving the `record` from the `RecordContext` with the `useRecordContext` hook. React-admin will set the `record` in this context based on the API response data at render time. If you pass a `source`, the field component needs to find the corresponding value in the `record` and render it.

Let's see an example for an API returning user records with `firstName` and `lastName` properties.

Expand Down

0 comments on commit 601a0d6

Please sign in to comment.