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

Cannot insert into hasura when it uses UUID as ID

I'm trying to use react admin with ra-hasura data provider, when I try to create a record where the id is a UUID which is actually auto generated by postgresql, the interface of react admin insert a UUID generated by the react admin itself as an id…
0
votes
1 answer

Not getting ID (it's undefined) of created record in redux-saga in React-admin

This is the problem. I wanted to catch ID of newly created record so I created custom watcher saga that listens to every "RA/CRUD_CREATE_SUCCESS". And my worker saga needs to get ID of newly created record so I can do second call to other endpoint…
0
votes
1 answer

Problems with react-admin components

I'm trying to use a TabbedShowLayout inside of Edit but this return a error related the missing props: print of the error Here is my code: export const BarberEdit = (props) => { const [id, setId] = useState(props.id); const [name, setName] =…
0
votes
1 answer

Add a custom filter drop down for react-admin List view

Question 1: I have a list view with a column for "Active": I want to allow the user to select Active/Inactive from a radio button group as a filter (or dropdown). I know react-admin provides filters for reference fields out of the box. What about a…
Dan G.
  • 529
  • 8
  • 21
0
votes
2 answers

ReferenceArrayInput usage with relationships on React Admin

I have followed the doc for the ReferenceArrayInput (https://marmelab.com/react-admin/Inputs.html#common-input-props) but it does not seem to be working with relationship fields. For example, I have this many-to-many relation for my Users…
0
votes
0 answers

Passing record information in ReactAdmin from parent FormTab through ArrayField child

I don't know if this is a ReactAdmin question or a basic React one. If I should remove a tag (or add a different one) please let me know. In a ReactAdmin application, I have an ArrayField nested inside a FormTab. In one of its components (DataGrid…
Scott Sauyet
  • 49,207
  • 4
  • 49
  • 103
0
votes
0 answers

React-admin: with custom username as id not displaying any form

In react admin v3, I want to display an edit my profile form, it will contain Form to edit my firstName, lastName, email, mobile Form to edit my password I want both form on the same page, with two submit button. I also want the saving to stay on…
Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
0
votes
1 answer

How properly implement mutation on show page but not to the current resource on react-admin

I have show page and this page should load data from it's resource but this page shouldn't update this resource. Instead of updating current resource's item this page should make different mutation. So for example i have users resource and i have…
Link
  • 669
  • 7
  • 20
0
votes
0 answers

Customizing Component to add Profile Image

We are using react-admin for our application. For our sign-up page, we have an option to pick a profile image. (This is using material-UI) How can we customize the InputImage component as per UI design? The Avatar design How do we extend and…
0
votes
1 answer

Map "defaultValue" and "source" of a react-admin text input to two different properties of the same object

I have a weird API endpoint where there are two properties for the same field. { id:"123", title: { rendered: "Hi, i'm rendered", raw: "

Hi, I'm the title

" } in the Edit form, I have a Component like so:
friendlyfire
  • 87
  • 1
  • 12
0
votes
4 answers

React Admin Confirmation Dialogue On Save

I'm trying to show confirmation dialogue on saving in react admin framework but saving functionality started breaking. Error --> Converting circular structure to JSON --> starting at object with constructor 'FiberNode' | property 'stateNode' ->…
0
votes
2 answers

React-admin title not displaying on navbar

Seems like a simple thing. How do I put a title on the navbar? Here's my App.js: import React from 'react'; import { Admin, Resource } from 'react-admin'; import { UserList } from './Users'; import { ItemList, ItemEdit, ItemCreate } from…
Dan G.
  • 529
  • 8
  • 21
0
votes
1 answer

How to hide multiple fields in react-admin ShowView?

I am trying to hide a set of fields based on the value of another field but the following will not display the conditional fields ever: export const ServiceShow = (props) => ( {controllerProps =>
vaizki
  • 1,678
  • 1
  • 9
  • 12
0
votes
1 answer

Where to check for token expiration and send refresh request

I have set up react-admin and am using it with the HydraAdmin component. My login request returns a JWT and a refresh token. I store these in localStorage and want to check whether the JWT is expired before sending requests. The problem is, where do…
Somebody
  • 347
  • 2
  • 14
0
votes
1 answer

React Admin - FileInput that uploads to a single flat key instead of an object

In react admin, if you have a FileInput, it requires a child field, and stores the file URL inside the child field. So for example { "photo": { "url": "https://url-to-image.com" } } and the corresponding react admin code is
user1558646
  • 145
  • 4
  • 9
1 2 3
99
100