React-Admin — Resource

Resource allows you to define a component for each CRUD operation, using the following prop names:

  • list (if defined, the resource is displayed on the Menu)
  • create
  • edit
  • show
import React from 'react';
import { Admin, Resource } from 'react-admin';
import jsonServerProvider from 'ra-data-json-server';

import { PostList, PostCreate, PostEdit, PostShow, PostIcon } from './posts';
import { UserList } from './posts';
import { CommentList, CommentEdit, CommentCreate, CommentIcon } from './comments';

const App = () => (
  <Admin dataProvider={jsonServerProvider('http://jsonplaceholder.typicode.com')}>
    <Resource name="posts" list={PostList} create={PostCreate} edit={PostEdit} show={PostShow} icon={PostIcon} />
    <Resource name="users" list={UserList} />
    <Resource name="comments" list={CommentList} create={CommentCreate} edit={CommentEdit} icon={CommentIcon} />
    <Resource name="tags" />
  </Admin>
);

Resource also accepts additional props:

  • name
  • icon
  • options

React-admin uses the name prop both to determine the API endpoint (passed to the dataProvider), and to form the URL for the resource.

React-admin will render the icon prop component in the menu.

options.label allows to customize the display name of a given resource in the menu.

<Resource name="v2/posts" options={{ label: 'Posts' }} list={PostList} icon={PostIcon} />
Category: React

Author: Yoga

Article
Tagcloud
DVA Java Express Architecture Azure CI/CD database ML AWS ETL nest sql AntV Next Deep Learning Flutter TypeScript Angular DevTools Microsoft egg Tableau SAP Token Regexp Unit test Nginx nodeJS sails wechat Jmeter HTML2Canvas Swift Jenkins JS event GTM Algorithm Echarts React-Admin Rest React hook Flux Redux ES6 Route Component Ref AJAX Form JSX Virtual Dom Javascript CSS design pattern