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
10
votes
2 answers

How to disable optimistic UI updates in react-admin?

Is it possible to disable optimistic UI in react-admin or is it configurable at runtime?
Ashim Saha
  • 363
  • 3
  • 9
9
votes
3 answers

react-admin: ERROR: The dataProvider threw an error. It should return a rejected Promise instead - easy fix?

In an react-admin 3.2.3 edit form I need to show related records (the list of job records) from a different resource. The relation is a bit weird and requires string parsing so I can't just use the built-in ReferenceField. That's why I am trying to…
elsni
  • 1,953
  • 2
  • 17
  • 35
9
votes
2 answers

The response to 'GET_LIST' must be like { data : [...] }, but the received data is not an array

I am trying to use the ra-data-simple-rest data provider. import React from 'react'; import { Admin, fetchUtils, Resource } from 'react-admin'; import simpleRestProvider from 'ra-data-simple-rest'; import { PostList } from './Posts'; const…
Hari K T
  • 4,174
  • 3
  • 32
  • 51
9
votes
1 answer

Is it possible to disable default sorting in React Admin?

I have simple question Is it possible to disable default sorting by column id? Or at least change it globally? Thanks for answer EDIT: To be more specific, I have REST API (OData) which returns "Id" instead of "id" so I have to set sort everytime I…
Allwe
  • 471
  • 1
  • 5
  • 18
9
votes
3 answers

How to disable delete action in List view in react admin?

Before version 2 you could just not pass remove prop to component. However now delete action is included by default in view and I can't find anywhere in docs how I can disable it.
transGLUKator
  • 642
  • 7
  • 17
9
votes
5 answers

How to reset filter values in react admin framework?

I have a filter component: export const PostsFilter = (props) => ( ); I need to add a reset button…
Sasha Kos
  • 2,480
  • 2
  • 22
  • 37
9
votes
1 answer

React Admin - How To Hide Actions Buttons

How could I hide the action buttons in the React-Admin 2.2.0 framework? For example, I want to hide just the export button, or show only the Refresh and Export buttons.
Katliss.26
  • 412
  • 3
  • 9
9
votes
2 answers

React Admin: Can I use another field for , other than "id"?

Is there any way to use a different reference field (other than id) for a ReferenceInput? For example: I have a languages resource, which I want to populate using a language_code field.Note, I don't want to use the id field of languages, I want to…
Ross
  • 135
  • 1
  • 8
8
votes
2 answers

React-admin: How to implement a autosave/background-save feature?

How to implement a autosave/background-save feature using react-admin? I want a feature when I am editing a rich input field, such as a rich text, a background saving will push my text to server, without touch my focus and edit position. I tried…
Jason
  • 546
  • 1
  • 4
  • 11
8
votes
2 answers

How to prevent flash of dashboard content while unauthenticated in react-admin?

According to an older comment and what I am experiencing with my app, react-admin may show the Dashboard when not authenticated for a brief moment right before redirecting to and showing the login dialog. The AUTH_CHECK call is asynchronous, and…
Christiaan Westerbeek
  • 10,619
  • 13
  • 64
  • 89
8
votes
0 answers

Using react-admin with snowpack

I want to use react-admin in a project with snowpack but I encounter the following error ✖ snowpack failed to load node_modules/ra-core/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js 'default' is not exported by…
thammada.ts
  • 5,065
  • 2
  • 22
  • 33
8
votes
4 answers

What is the easiest way to show a confirmation dialog in react-admin?

In a react-admin project I created my own toolbar button that should display a confirmation dialog, similar to the JavaScript alert but not quite as ugly. Only when the user clicks OK, things should happen, in my case some database operations. is…
elsni
  • 1,953
  • 2
  • 17
  • 35
8
votes
3 answers

React-admin JWT authentication refresh token problem

I want to implement my own authProvider for react-admin but I'm stuck. I use a Django-Rest-Framework backend and a JWT token authentication system. I want to refresh the JWT token if it's almost expired before every request. According to the…
ilo
  • 316
  • 2
  • 12
8
votes
1 answer

How to expose a property which depends on a serialization group from API-Platform to react-admin?

I use Changing the Serialization Context Dynamically in my application to apply the admin:write group when the user is an admin. So that an user on the admin will be able to update this property. The context builder has this…
A.L
  • 10,259
  • 10
  • 67
  • 98
8
votes
5 answers

Adding custom page without authentication in react-admin

I want to add a signup page to my react-admin web portal. Since react-admin do not provide a signup page, I created a custom page and added it to custom routes: customRoutes.js import React from 'react'; import { Route } from…
arpanmangal
  • 1,770
  • 1
  • 17
  • 34