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
6
votes
3 answers

Custom layout in SimpleForm component on react-admin

I want to create a custom two-column-grid layout on my react-admin project on Edit and Show pages. I want to display selectboxes and the imageupload area on the left column, and the text inputs on the right column by using only one…
selens
  • 388
  • 4
  • 13
6
votes
1 answer

Custom Routes in react admin

I have created a custom route { return
SuperManort
  • 67
  • 1
  • 5
6
votes
2 answers

React Admin displays very messed up

My RA project renders fine when deploying locally, however, when I copy my build directory to an S3 bucket for deployment, it renders all messed up. Sometimes it works, but most of the time it renders like the below image. It works fine in both…
Roger
  • 91
  • 5
6
votes
2 answers

Code splitting a react-admin app with a bundle before and after login

Consider the react-admin app like presented below. I'm planning to code split in a way that everything in './posts' and './users' is only loaded after the user is logged in. I plan to use the dynamic import() syntax that I can use so that webpack…
Christiaan Westerbeek
  • 10,619
  • 13
  • 64
  • 89
5
votes
2 answers

useDataProvider hook for custom methods

I call const dataProvider = useDataProvider() in my component and can use the default methods like dataProvider.getList("resource",{}) without any issue. Then, I expanded my DataProvider with a custom get method for retrieving objects that don't…
Heikkisorsa
  • 740
  • 9
  • 31
5
votes
3 answers

React-admin rendering runtime resources multiple times

I'm following this design pattern from React-admin to define the parent Team resource, but the useEffect hook is being called 4 times on every page refresh The context provider is just to be able to pass the Teams list to a select in the layout, if…
Mojimi
  • 2,561
  • 9
  • 52
  • 116
5
votes
3 answers

React-admin Datagrid: expand all rows by default

I have a react-admin (3.14.1) List using a Datagrid, where each row is expandable. Does anyone know how to expand all the rows by default? Or expand a row programmatically? I've checked the Datagrid code in…
chichilatte
  • 1,697
  • 19
  • 21
5
votes
3 answers

Can my empty TextInput value be sent to the DataProvider as empty string instead of converted to null?

I'm using a in a and when I clear out the value at runtime, react-admin sets the property's value to null when it sends the values to the DataProvider. I would like to store empty strings instead of null. Is that possible?…
kmb
  • 85
  • 5
5
votes
3 answers

React Admin: onSuccess does not work properly on Component

onSuccess function does not work properly on react-admin, my code: const onSuccess = () => { redirect('list', props.basePath); };
5
votes
0 answers

Edit multi select input in react-admin for one-to-many or many-to-many relationship?

What is the current "out-of-the-box" way for editing many-to-many relationships in react-admin? More specifically, is there any way to SelectArrayInput or AutoCompleteArrayInput over a referenced table? My first table is stream stream table My…
Amit Kumar
  • 169
  • 1
  • 10
5
votes
1 answer

How to limit column width on react-admin List View

On a list view with few columns, the columns are very wide. I'd like to limit the width of at least some of these columns (except the last one): Still trying to come up to speed on react-admin, react, and material-ui. I'm sure there's some styling…
Dan G.
  • 529
  • 8
  • 21
5
votes
2 answers

React-Admin: How do I hide the "Checkbox" with the Datagrid ?

Within my App, we have permissions like ADD/DELETE based on roles. Admin has all permissions to add, delete, edit the records customers don't have the delete permissions. I therefore want to hide the delete checkbox within the for…
Nitish Kalra
  • 115
  • 3
  • 7
5
votes
4 answers

How to wait for FETCH before rendering DATA in Functional Component?

I'm trying to display a component till the DATA fetch is a success,after which I display a Child component. I don't understand why the state is not updated... How can I handle this? I'm using react-admin but it doesn't really matter I…
karamasov
  • 51
  • 1
  • 2
5
votes
1 answer

Multi-part form data in react-admin

I'm trying to use react-admin to send data to my custom API. I want to send files, I can see that there is , I'd like to send that data as multi-part form data. I have come across the base64 encoding help page, as a newcomer to react, it is hard for…
Akos Veres
  • 63
  • 1
  • 4
5
votes
0 answers

react-admin: TypeError: (0 , n.default) is not a function

After switching from using next.js to a simpler parcel/webpack build, I've been trying to solve this particular error for over a week to no avail. I'm out of ideas how to solve this so I hope some one on here can help. Full error: TypeError: (0 ,…
MLyck
  • 4,959
  • 13
  • 43
  • 74