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

How is the correct way to have multiple dataProviders in react-admin?

I'm trying to use multiple dataproviders in a react-admin project but I have an error: Warning: Missing translation for key: "dataProvider is not a function" function.console.(anonymous function) @ index.js:1452 I have my App.js like this: import…
Javier C.
  • 7,859
  • 5
  • 41
  • 53
8
votes
6 answers

Use on React-Admin dashboard

I'm using react-admin v2.3.2 with a custom dashboard component as shown in the react-admin tutorial.
Thomas Halwax
  • 193
  • 1
  • 10
8
votes
1 answer

react-admin - How to set input values based on another

i'm trying to create a ZIP code input that loads street, state and city values automatically in a Create form using React-Admin. How can I populate the inputs based on the onBlur event of the zip code input? The best result i achieved is the…
Gabriel Marques
  • 276
  • 1
  • 3
  • 15
8
votes
1 answer

React Admin - Create and edit in modal

Following the discussion in https://github.com/marmelab/react-admin/issues/850, did someone manage to make a create / edit form into a modal? Thanks, Nicolas
Nicolas Kern
  • 279
  • 2
  • 3
  • 11
7
votes
2 answers

Use server-side validation response in react-admin

In my app using react-admin I have a few forms where the validation must be performed on the server side. My API (implemented with api-platform) returns a 400 response with a key in its body that contains an array of the constraint violations, keyed…
Rad80
  • 823
  • 7
  • 17
7
votes
3 answers

Is it possible to add user search filters to a ReferenceManyField in React Admin v3?

With React Admin it is possible to add Filters to a List component. An example of this can be seen in the demo: https://marmelab.com/react-admin-demo/#/commands The code for this particular component:…
Bas de Raad
  • 556
  • 1
  • 6
  • 15
7
votes
1 answer

How to update data provider headers dynamically in hasura react admin?

I'm trying to do an application that needs authentication using react-admin and the hasura data provider, i need to change the headers of the after the login success. Right now, the headers are only updated when i reload the page, otherwise, this…
Mihael Zamin
  • 195
  • 1
  • 1
  • 9
7
votes
1 answer

How to prevent get request from being send if the length of the query field is short in react-admin

I'm using react-admin and trying to create a filter with autocomplete field that will make a query as I type and will only start sending the query when the search criteria length is longer then 2. I'm currently using shouldRenderSuggestions inside…
Adi Bnaya
  • 473
  • 4
  • 14
7
votes
4 answers

Can you disable the React-Admin Undo feature in config?

The Undo feature is a great, but it can cause inefficiencies during development cycles. Is there an easy way for us to disable it in our staging environment, or at least lower the timeout?
Anthony Main
  • 6,039
  • 12
  • 64
  • 89
7
votes
1 answer

Cookie-based authentication via REST API in react-admin

I'm new to react-admin. I already read through all the questions here in stackoverflow, and google'd for my question too, but did not find any useful solution. I am setting up React-admin to replace an existing admin page for one of my projects. I…
Reka Karolyi
  • 219
  • 4
  • 14
7
votes
3 answers

Warning: Missing translation for key: "";

I am using react-admin for creating my website. But i am getting this warning from list page every time 'Warning: Missing translation for key: "";' const ListTitle = () => { return User Agents; } const SitemapFilter = props => ( …
Aswathy Balan
  • 484
  • 1
  • 4
  • 15
7
votes
3 answers

How to implement forgot password page on react-admin

I have a dashboard implemented on react-admin. The authentication process was done following this tutorial. Now I need to implement a forgot password screen, but the problem is that this screen needs to be accessible without being logged in... I…
Alex Mantaut
  • 3,657
  • 3
  • 35
  • 45
7
votes
4 answers

Support for resource nesting

I am wondering, is it possible to configure DataProvider/Resource/List to support REST urls like api/users/1/roles? For RESTful API it is very common use case to get childs of certain parent entity, but I cant figure it how to setup React Admin and…
Allwe
  • 471
  • 1
  • 5
  • 18
7
votes
1 answer

How to reuse subresource data for referenced inputs in React-admin?

In react-admin documentation the use of ReferenceArrayInput is for this kind of data structure: { id: 1, groups: [1, 2, 3] } And then:
genesis
  • 450
  • 4
  • 10
7
votes
1 answer

react-admin and connection pagination

I currently have a GraphQL API that uses connection based pagination as defined in https://graphql.org/learn/pagination/ which is what the Relay client uses. I have looked at ra-data-graphql-simple but that expects the GraphQL server to return…
Owen Ben Davies
  • 259
  • 2
  • 8