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

react-admin Create a custom page which can be accessed from menu sidebar

I'm new to react-admin, how can I create a custom page that can access from menu sidebar? What I'm looking for is similar to this tutorial: https://marmelab.com/blog/2019/03/07/react-admin-advanced-recipes-user-profile.html but I need to be able to…
Yaiba
  • 571
  • 7
  • 14
5
votes
0 answers

How to do local sorting and filtering with React Admin?

I created a dashboard using React-Admin, in that application when I am trying to sort table based on a specific column, a fetch request is made to the backend and querystring is passed along with the URL, currently my backend is not setup to read…
debchakra
  • 71
  • 1
  • 3
5
votes
2 answers

React-admin: How to Pass more parameters to a dataProvider for type GET_LIST

I want to pass one custom parameter to the Admin's dataProvider for type 'GET_LIST'. I have something like this in App.js:
WiXSL
  • 689
  • 5
  • 16
5
votes
1 answer

Input value not updating with custom input in react-admin

i have looked around at some other examples and this works right up to the point where i would want it to update record-form in the redux dev tools.. This is my first shot at a custom input so i am not surprised but figure maybe someone can give me…
Greg Belyea
  • 858
  • 1
  • 5
  • 15
5
votes
1 answer

React setState does not set state during a while loop

I want to avoid data multiplication, so i wanted to create a loop for calling my dataprovider for different site_id's. I created a while loop and set the state values within this while loop. What I realized that from my 2 element array (I have 2…
Reka Karolyi
  • 219
  • 4
  • 14
5
votes
1 answer

React-Admin: Implementing a Custom Request Type

Is it possible to implement a custom request type in a custom provider in the react-admin framework? My Use Case In my case I have 2 separate cases of reference fields. 1. Reference ID field (normal) api -> users/1 api -> comments/1 2. Sub Entity…
Ben Winding
  • 10,208
  • 4
  • 80
  • 67
5
votes
2 answers

react-admin: handle null on ReferenceFields

I have a ReferenceField as follows: It works nice but the problem is sometimes user_id might be null and that causes the loading bar…
petekaner
  • 8,071
  • 5
  • 29
  • 52
5
votes
2 answers

How to redirect to some other route after successful authentication in react-admin

I have been looking for a solution to redirect to specific url after successful authentication in react-admin, when I paste http://localhost:1234/#/students/sdf2343afs32 on the url if already signed-in then I'm getting the user detail page but if…
5
votes
3 answers

Background image in react-admin Login page

I want to use a image to be put in as background image of login page in react-admin how can I do this ? P.S: I'm using TypeScript
Anirudh Sharma
  • 129
  • 1
  • 3
  • 9
5
votes
2 answers

Many to many relationship react-admin

Im trying to show in a Datagrid a Field that is in a many to many relationship (intermediate table). I have these tables: group - group_subject - subject A group can have many subjects A subject can be connected with many Groups group_subject…
oskrgg
  • 101
  • 1
  • 9
4
votes
2 answers

Create multiple resources from the same endpoint in React Admin to have different filters applied

I need to create different routes in React admin, all based on the same endpoint but with a different filter. My need is that I need a Menu entry to show all properties with status = approved, all properties with status = review and so on. I tried…
Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192
4
votes
1 answer

How to have a parent/global Resource in React-Admin?

Context: The database structure of my application starts at the Company level, a user may be part of more than one company, and he may switch Companies at any point, every other Resource resides inside Company Every time the user switches company,…
Mojimi
  • 2,561
  • 9
  • 52
  • 116
4
votes
0 answers

How to edit items inside en Array Input in React admin?

I have an object that contains objects and each of them has an array of items, I want to attach to each of them an edit button for viewing and deleting In React-admin, but something in my code fails and every time I press the buttons everything gets…
4
votes
0 answers

React Admin: on foreign key fetches the data but does not render child

I am using react-admin 3.1.1 I have one to one relationship between employee and user through email. I am using graphql on backend. Here is the code:
Filozof6
  • 41
  • 1
  • 2
4
votes
0 answers

How can I setup an admin panel for my Next.js app

I'm developing a Next.js app and need an admin panel to manage data, users and posts. I'm thinking it would be better to setup the panel as a separate app instead of a new path in the current app. I've looked at react-admin but it is regular…
jinsley8
  • 81
  • 5