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

How to use react-admin's ChipField if there is no field/column name?

I have a CheckboxGroupInput field like this: which produces json likes this for the fruits field when the user…
elsni
  • 1,953
  • 2
  • 17
  • 35
4
votes
1 answer

How to create a submit button in react-admin which changes appearance and behaviour depending on form data and validation

In a complex tabbed form in react-admin I need to have two submit buttons, one is the regular save button and one for altering the "status" field (advancing one workflow step) and saving the form. The save butten should only become active if all…
elsni
  • 1,953
  • 2
  • 17
  • 35
4
votes
2 answers

Server Side Validation Response react admin

How I can show error response message from my API server react-admin version 3.0 ? This variant doesn't work https://github.com/marmelab/react-admin/pull/871 enter image description here
4
votes
2 answers

React-Admin is populating my with same element

codesandbox.io I'm trying to create a nice admin dashboard with react-admin.As using spring in my backend and this is how am sending data to react-admin: @GetMapping("admin/user") ResponseEntity> getAll() { System.out.println(new…
Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86
4
votes
3 answers

How can I use an asynchronous javascript function like fetch inside a FormDataConsumer

I need to use a fetch inside the FormDataConsumer tag but it seems FormDataConsumer does not support async functions. This code didn't work for me: { async ({ formData, scopedFormData, getSource, ...rest }) => { return…
4
votes
1 answer

react-admin: SimpleForm in Isolation

Being a big fan of Storybook I like to test my components in Isolation. Especially Forms. However, I'm having a very hard time figuring out how the heck I can get my forms or even a single form field to work in isolation. (without Edit, Create,…
MLyck
  • 4,959
  • 13
  • 43
  • 74
4
votes
1 answer

Including React-Admin In Another Application *without Redux*

I'm trying to upgrade React Admin to V3 but I'm facing issues. I'm including RA in my SPA when the user types the route myapp/admin. My app includes a custom route to include the Admin component when the route is hit. More or less like so: // in…
7hibault
  • 2,371
  • 3
  • 23
  • 33
4
votes
1 answer

react-admin: Handle click event in Custom Field within a

In our react-admin application, first we display a products list. On each row we also display a TextField (to allow user input number of copies) and a 'Print' button. The snippet as below: export const ProductList = props => (
Trung
  • 1,012
  • 13
  • 26
4
votes
2 answers

In react-admin, how can i update my current view when i using fetch to get data?

In react-admin, All I know is that the framework provides two ways for me to update, they are setting dataProvider refresh to true and refreshbutton. Now my situation is that I have a dialog which used to pay. And the pay request is not restful api.…
holy zheng
  • 81
  • 5
4
votes
0 answers

Endless scroll for List Component

Is there any way to implement proper endless scroll for react-admin List Component? By "proper" I mean loading data only partially at start and then loading more whenever user scrolls up/down?
4
votes
1 answer

How to configure endpoint and custom graphql query in React-Admin

I'm setting up a react-admin app, that needs to connect with a Hasura Service using a graphql provider. To do so, I need to pass for the provider the endpoint "/v1/graphql" and the query with the selects subfields. Like this: query MyQuery { …
7xRobin
  • 341
  • 1
  • 4
  • 11
4
votes
2 answers

Error: useForm must be used inside of a
component - Electron

What you were expecting: I followed the upgrade guide for linking two components and started using const form = useForm() instead of dispatch. The change works in Chrome browser but when I open in Electron I get the error: Error: useForm must be…
4
votes
1 answer

Stay on the edit page if get server side error

I am now using the react-admin framework, when the user clicks the Save button on the Edit page. Normally it will go to the List page and show an undo notification at the bottom, but at that time server-side gets validation error (for example, image…
sunfly
  • 191
  • 6
4
votes
1 answer

Display total of grid column values in react-admin

In react-admin I have a page that shows a list of balances, it looks like this: // extra code not included export const BalanceList = props => ( } actions={} {...props} perPage={-1}>
firepol
  • 1,731
  • 22
  • 39
4
votes
4 answers

How to start with left menu collapsed

Is there an easy was to start with the left menu collapsed or do I need to update the layout ? I'd like to have the menu collapsed by default with only the icons visible. Thank you.
Christophe
  • 85
  • 7