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
4 answers

Preserving line breaks with React-Admin / Material UI's Textfields?

I'm using React-Admin and have a field in my database that contains linebreaks (\n). When I output this on a page like this: The linebreaks are ignored and everything runs together. How can I make the linebreaks…
matt
  • 723
  • 1
  • 12
  • 20
4
votes
2 answers

How do you integrate aws-amplify authentication with react-admin?

I'm trying to implement aws-amplify to my react-admin. Especially for the Authentication part. Instead of having something like this: react-admin with Amplify NavBar on top I'm looking to have "UserName" and "LogOut" button from "aws-amplify"…
4
votes
1 answer

ReferenceInput with nested CheckBoxGroupInput behaving strangely

I have looked around for many hours and tried various things but alot of the examples i see for CheckBoxGroupInput simply have a hardcoded list of choices associated which is a bit useless... My scenario here is that i have a list of tags that i…
Greg Belyea
  • 858
  • 1
  • 5
  • 15
4
votes
2 answers

react-admin exclude "record" from the redux-form

I have an issue when I send SimpleForm (edit) request with react-admin. The request includes more parameters than I have in the form's fields. For example I have form:
llioor
  • 5,804
  • 4
  • 36
  • 44
4
votes
0 answers

Get data from a custom endpoint in react-admin

I'm using react-admin with data that I get from a restAPI data source that I can customize for my needs, I've added a standard resource with only a list and an edit attributes: When I…
Adi Bnaya
  • 473
  • 4
  • 14
4
votes
1 answer

Maximum call stack size exceeded in react-admin with ra_data_graphql_simple when schema with nested object

I dove in head first to try react-admin as the admin solution for some simple data entry for an application but i find the docs lacking and i have searched for a solution to this online after many hours of debugging. My Problem: When nested objects…
Greg Belyea
  • 858
  • 1
  • 5
  • 15
4
votes
3 answers

implement BackButton in react-admin

I need to implement a in react-admin for example when I open show page for a resource I need able to back to the list page. Can you guide me to implement this? I'm not familiar with react-admin routing mechanism. Now I'm using this…
b24
  • 2,425
  • 6
  • 30
  • 51
4
votes
1 answer

How to pre populate the ImageField inside ImageInput in Edit Form, or the right approach to take

I am working with react-admin and in the functionality.. I need to display the original picture in an ImageField but if i choose to drag and drop a new picture then i need to update that ImageField with the new picture. I can't seem to see any…
Greg Belyea
  • 858
  • 1
  • 5
  • 15
4
votes
0 answers

Render field conditionally based on a ReferenceInput's selected record property

So the code below works great, but I'm using a ReferenceField just to fetch the record selected in the ReferenceInput. This feels a bit odd. Any advice on how I SHOULD do this ? My use case : // js-ish description of my datamodel { id, name,…
Armel Larcier
  • 15,747
  • 7
  • 68
  • 89
4
votes
1 answer

Sorting a list by a referenced field react-admin

I started using react-admin and is basically works fine. However I have some trouble using the ReferenceField. The REST API I'm calling returns e.g. the following JSON data: /language { "language": [ { "id": 0, "name": "Language…
Robert Strauch
  • 12,055
  • 24
  • 120
  • 192
4
votes
1 answer

I need to create admin page using React and MongoDB

I have mongoDB installed on amazon server and front-end, written on React.js. I need to create Admin page using 'react-admin' but I don't know how to make it with my mongoDB because they do not provide dataProvider function that 'react-admin' uses…
4
votes
0 answers

VSCode "Go to definition": How to display non-compiled ES6 files?

In a Node.js app with installed npm dependencies, I'm importing a module like that: import { Admin } from 'react-admin'; When I hover on the 'Admin' name and choose 'Go to definition', VSCode displays the compiled source, taken from…
François Zaninotto
  • 7,068
  • 2
  • 35
  • 56
4
votes
1 answer

Cannot read property 'hasOwnProperty'

After an update, if the status code was an 422 i have a notification with this message : Cannot read property 'hasOwnProperty' of undefined TypeError: Cannot read property 'hasOwnProperty' of undefined at validateResponseFormat…
sorcer1
  • 117
  • 3
  • 11
4
votes
0 answers

More fields in React-admin login page

I need to insert one more field in the Login page, therefore, one other entry in the JSON login request and, although I managed to insert the field in the login page (as a FormControl with Selects), I'm having trouble in inserting the selected…
4
votes
1 answer

React Admin - List View ⋮ "More Options" Button

I'm using the React-Admin framework and want to combine the button actions to a single ⋮ options button. Basically, I want to turn this: Into This! I think it just looks a lot less cluttered and the ⋮ button is widely used for more options. Is…
Ben Winding
  • 10,208
  • 4
  • 80
  • 67