Questions tagged [react-admin]

A frontend Framework for building admin applications running in the browser on top of REST/GraphQL APIs, using ES6, React and Material Design. Previously named admin-on-rest. Open sourced and maintained by marmelab.

Links

Features

  • Backend Agnostic: Connects to any API (REST or GraphQL, see the list of more than 45 adapters)

  • All The Building Blocks You Need: Provides hooks and components for authentication, routing, forms & validation, datagrid, search & filter, relationships, validation, roles & permissions, rich text editor, i18n, notifications, menus, theming, caching, etc.

  • High Quality: Accessibility, responsive, secure, fast, testable

  • Great Developer Experience: Complete documentation, IDE autocompletion, type safety, storybook, demo apps with source code, modular architecture, declarative API

  • Great User Experience: Optimistic rendering, filter-as-you-type, undo, preferences, saved queries

  • Complete Customization: Replace any component with your own

  • ☂️ Opt-In Types: Develop either in TypeScript or JavaScript

  • ‍‍‍ Powered by MUI, react-hook-form, react-router, react-query, TypeScript and a few more.

At a Glance

// in app.js
import * as React from "react";
import { render } from 'react-dom';
import { Admin, Resource } from 'react-admin';
import restProvider from 'ra-data-simple-rest';

import { PostList, PostEdit, PostCreate, PostIcon } from './posts';

render(
    <Admin dataProvider={restProvider('http://localhost:3000')}>
        <Resource name="posts" list={PostList} edit={PostEdit} create={PostCreate} icon={PostIcon} />
    </Admin>,
    document.getElementById('root')
);

The <Resource> component is a configuration component that allows to define sub components for each of the admin view: list, edit, and create. These components use MUI and custom components from react-admin:

// in posts.js
import * as React from "react";
import { List, Datagrid, Edit, Create, SimpleForm, DateField, TextField, EditButton, TextInput, DateInput, useRecordContext } from 'react-admin';
import BookIcon from '@mui/icons-material/Book';
export const PostIcon = BookIcon;

export const PostList = () => (
    <List>
        <Datagrid>
            <TextField source="id" />
            <TextField source="title" />
            <DateField source="published_at" />
            <TextField source="average_note" />
            <TextField source="views" />
            <EditButton />
        </Datagrid>
    </List>
);

const PostTitle = () => {
    const record = useRecordContext();
    return <span>Post {record ? `"${record.title}"` : ''}</span>;
};

export const PostEdit = () => (
    <Edit title={<PostTitle />}>
        <SimpleForm>
            <TextInput disabled source="id" />
            <TextInput source="title" />
            <TextInput source="teaser" options={{ multiline: true }} />
            <TextInput multiline source="body" />
            <DateInput label="Publication date" source="published_at" />
            <TextInput source="average_note" />
            <TextInput disabled label="Nb views" source="views" />
        </SimpleForm>
    </Edit>
);

export const PostCreate = () => (
    <Create title="Create a Post">
        <SimpleForm>
            <TextInput source="title" />
            <TextInput source="teaser" options={{ multiline: true }} />
            <TextInput multiline source="body" />
            <TextInput label="Publication date" source="published_at" />
            <TextInput source="average_note" />
        </SimpleForm>
    </Create>
);
1781 questions
7
votes
1 answer

there is a way to have multiple sorting in react-admin?

I have a nodejs backend using epilogue, which supports multiple sort values like: ?sort=first_name,-rating . I am using a pretty standard dataProvider and I wondering how enable this feature in a react-admin List when I clicked over a label field.…
genesis
  • 450
  • 4
  • 10
7
votes
2 answers

Nested menu (sub-menu)

I'm trying to implement Sub-menu (nested menu). It's worth to mention that I'm using hydra component and don't have previous experience with redux (started learning it a few days ago because of this specific problem). I've followed the example…
Dejan Belic
  • 101
  • 1
  • 1
  • 4
7
votes
6 answers

How to get index of SimpleFormIterator

I want to access index of simpleFormIterator. How can I do that? I have a code something like that I'm trying to access it in the SelectInput component
Cansel Muti
  • 598
  • 2
  • 9
  • 22
7
votes
2 answers

React Admin - how to call dataProvider with nested path like abc/def

React-admin's Resource component maps name prop value to an endpoint. E.g. to access data from . http://example.com/abc, your Resource component looks like this: What i want to access resource at…
Sebastian
  • 1,225
  • 1
  • 16
  • 27
7
votes
1 answer

Show server-side validation errors after failed form submit

How can I show validation messages after failed form submit? API request returns HTTP 400 'application/problem+json' response and contains violations as a list with field path. https://www.rfc-editor.org/rfc/rfc7807#section-3 { "type":…
Ismail Baskin
  • 374
  • 6
  • 9
6
votes
1 answer

add Multiple records at one in Create view

I'm trying to create multiple posts at once in a react-admin Create view. It's similar to one-to-many whereby one author can create multiple posts at once in a Create component in react-admin. I haven't found a working way when using a TabbedForm.…
ubeezy
  • 61
  • 2
6
votes
1 answer

Unable to remove delete button from Edit component of react-admin

I have successfully removed delete button from datagrid by suppling props bulkActionButtons={false} but Unable to remove delete button from Edit component of react-admin export const UserEdit = (props) => (
6
votes
2 answers

OpenAPI support in react-admin?

The react-admin homepage prominently shows an OpenAPI (formerly Swagger) logo, but I can't find the relevant Data Provider in the list or on GitHub. Is it best to use ra-data-simple-rest and extend it, or am I missing something and is there a…
Niek
  • 1,709
  • 2
  • 11
  • 10
6
votes
1 answer

How to handle cursor-based pagination in React-Admin?

My API provides cursor-based pagination not offset-limit pagination, so is hard to match up to the page: {int} and perPage: {int} configuration that React-Admin provides for GET_LIST and GET_MANY_REFERENCE. Cursor-based pagination is used by many…
Gareth S-B
  • 81
  • 4
6
votes
4 answers

React-admin: how to hide refresh button from AppBar?

I'm creating admin ui based on react-admin and currently searching for a solution to hide the refresh button from the AppBar. Disabling export button was trivial (exporter={false}). Is there anything equally simple for RefreshButton? I couldn't…
Nis
  • 83
  • 1
  • 7
6
votes
1 answer

Get ReferenceManyField Count?

How do you get to display a count of a "ReferenceManyField" component? Here is the thing, I am listing organizations and I would like to get each of them their users counts. Fetch organizations: GET…
6
votes
0 answers

React-admin: Missing headers object in data provider

I am trying to create a custom data provider for my API. I am able to login and GET_LIST but unable to process the received data. I have adapted the required output format for the API responses and also included the Content-Range header. With…
6
votes
1 answer

In Custom App with embedded Admin, adminSaga doesn't work

I am trying to embed React Admin (RA) into an existing React-Redux application and following the documentation here: https://marmelab.com/react-admin/CustomApp.html While I have managed to successfully set up RA to use the root store, I am having…
charlesj
  • 81
  • 1
  • 5
6
votes
1 answer

Custom path for resource route in react-admin

Is there any way to specify custom paths for resources? Example: If it's not possible "per resource", can we for example have all the CRUD pages be under a same basepath like: /crud/{/$resource.name}…
E2zin
  • 73
  • 1
  • 7
6
votes
2 answers

React-admin - Create sub menu

How to create sub menu in react-admin, because in admin-on-rest i can use prop menuItems in MenuItem Component. Does react-admin have same props for this case? I try create my own component, but with prop primary in ListItemText for give list name…
Miftah Faris
  • 61
  • 1
  • 2