The <Resource> component
<Resource> components define the CRUD routes of a react-admin application.
In react-admin terms, a resource is a string that refers to an entity type (like ‘products’, ‘subscribers’, or ‘tags’). Records are objects with an id field, and two records of the same resource have the same field structure (e.g. all posts records have a title, a publication date, etc.).
A <Resource> component has 3 responsibilities:
- It defines the CRUD routes of a given resource (to display a list of records, the details of a record, or to create a new one).
- It creates a context that lets every descendant component know the current resource name (this context is called
ResourceContext). - It stores the resource definition (its name, icon, and label) inside a shared context (this context is called
ResourceDefinitionContext).
<Resource> components can only be used as children of the <Admin> component.
Usage
For instance, the following admin app offers an interface to the resources exposed by the JSONPlaceholder API (posts, users, comments, and
