diff --git a/UPGRADE.md b/UPGRADE.md index 4ae5d0cbbc6..e3245300f51 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -470,6 +470,51 @@ export const PostList = () => ( ); ``` +## `useListContext` No Longer Returns An `ids` Prop + +The `ListContext` used to return two props for the list data: `data` and `ids`. To render the list data, you had to iterate over the `ids`. + +Starting with react-admin v4, `useListContext` only returns a `data` prop, and it is now an array. This means you have to update all your code that relies on `ids` from a `ListContext`. Here is an example for a custom list iterator using cards: + +```diff +import * as React from 'react'; +import { useListContext, List, TextField, DateField, ReferenceField, EditButton } from 'react-admin'; +import { Card, CardActions, CardContent, CardHeader, Avatar } from '@material-ui/core'; +import PersonIcon from '@material-ui/icons/Person'; + +const CommentGrid = () => { +- const { data, ids, loading } = useListContext(); ++ const { data, isLoading } = useListContext(); +- if (loading) return null; ++ if (isLoading) return null; + return ( +