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
4
votes
1 answer

The new , deprecated-message of React-Admin

I have this message in the Chrome console since I updated react-admin to version 3.10.0, I tried to dig into the document but can't find any information or example. Anyone encounter this, or luckily any members of react-admin seeing this, please…
tan
  • 41
  • 4
4
votes
0 answers

Why does react-admin call getOne after delete, on the deleted object, in optimistic rendering mode?

We see that as soon as we call a 'delete' operation on the data provider, that react-admin pushes a CRUD_GET_ONE action onto the optimisticCalls array in usedataProvider. Then after the server response on the delete operation, this is replayed and a…
Bart007
  • 111
  • 6
4
votes
1 answer

Element type is invalid: expected a string (for built-in components), the way I do the import seems good

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up…
Dimitri Danilov
  • 1,338
  • 1
  • 17
  • 45
4
votes
1 answer

React-admin: Having an error when using the custom login page shown in the docs

I'm having this error when trying to use the custom login page from the react-admin official docs. index.js:1 Warning: Failed prop type: The prop `theme` is marked as required in `ThemeProvider`, but its value is `undefined`. In MyLoginPage.js, I…
4
votes
2 answers

How to share an instance between 2 List components in a react-admin Resource

This is how components are instantiated in react-admin, but now I need to share the notifications instance between the PostList and the UserList. I would like to avoid a singleton. Is it possible to pass the 'notifications' object somehow to the…
gal007
  • 6,911
  • 8
  • 47
  • 70
4
votes
3 answers

React-admin CheckboxGroupInput check some checkboxes by default

how to make some checkboxes checked by default } initialValue={[{ id: 4, checked: true }]} // don't work …
Safi Nettah
  • 1,160
  • 9
  • 15
4
votes
1 answer

Add "forgot password" link to react-admin's login page

I am building an admin web interface using react-admin and at the moment, I am trying to find a way to add a link under the Login button on react-admin's login page so that I can take the user through the account recovery process. I have everything…
znovotny
  • 193
  • 2
  • 8
4
votes
0 answers

React admin login using customRoute not rerendering resources/drawer

I am using react-admin for a dashboard. Everything works fine, but using login on a custom page (using customRoutes) is not rererendering the drawer after the redirect. Those are my custom routes: export default [
user3125470
  • 109
  • 10
4
votes
2 answers

Not able to upload Image with ImageField in EDIT mode for react-admin

Using React Admin I am creating a dashboard for one of my clients and I have a requirement where I have to add the products of the client, out of the many fields there is one Image field too where I have to upload an image which serves in the API…
Nitish Kalra
  • 115
  • 3
  • 7
4
votes
1 answer

Using SimpleForm inside DataGrid and ReferenceManyField | react-admin

actually i try to use a SimpleForm inside a Datagrid and ReferenceManyField to show a joined table and also change this data. Showing the data and deleting works pretty fine but everytime i click on Save i get the following Error: ` Uncaught…
MW00
  • 95
  • 1
  • 9
4
votes
2 answers

How to change the title on each page custom in react-admin

I want to change the title on each page to custom in React-Admin Is there a specific property in the Recorse or list or edit or create composites? please guide me Thanks enter image description here
4
votes
1 answer

How to display a logo on the AppBar component of react-admin?

Simple react-admin app. Trying to display a logo. I have the app title and a placeholder for the logo shows up, but no picture. Tried both a .svg and .png. Here's what it looks like: And here is the custom AppBar conponent: const CustomAppBar =…
Dan G.
  • 529
  • 8
  • 21
4
votes
0 answers

How to set fixed column width in react-admin List - Datagrid?

I have used makeStyles to change TextField padding within a column, which increases the column, for example but cannot figure out how to set fixed width for the column. It always auto-sizes it whatever I try. I want to make it narrower (id column)…
Alex1844
  • 313
  • 2
  • 8
4
votes
2 answers

React-admin: doesn't work with custom dataProvider

I'm trying to use element with custom dataProvider and getting this error: Missing translation for key: "dataProvider is undefined" It happens even if my data provider looks like this: import jsonServerProvider from…
4
votes
1 answer

How to call getSource within Nested ArrayInput / FormDataConsumer in react-admin

I'm following this documentation to use FormDataConsumer to show / hide inputs. But I have a nested ArrayInput / FormDataConsumer as below: export const MyClassCreate = ({ permissions, ...props }) => (
paulito415
  • 194
  • 1
  • 9