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

Is it possible to disable sorting for particular column with customfields in React Admin

I have a custom field for user status but I want to disable the default sorting on that column. like when we use predefined fields like
Three Doc
  • 43
  • 4
0
votes
1 answer

React-admin MenuItemLink onClick not working

I've got react-admin v3 running very smoothly, but I'm struggling with one point. I've got a custom user menu component set up as below, but the handleClick event isn't called at all - nothing in the console, and no window opening. Instead, the…
BlakeyUK
  • 83
  • 1
  • 9
0
votes
1 answer

How to call an backend api and fetch result to show on react admin dashboard?

I have an API for my backend which gives some JSON data in response. React Admin allow data to be shown using a DATA provider. I have tried all the data provider but none of them give me the results. I have this API Method: GET…
CoderXT
  • 122
  • 6
0
votes
1 answer

Style a RadioButtonInput used as a filter on a react-admin list?

I am using a RadioButtonInput control wrapped in a Filter component used on a List component. It works, but look a bit big: I've tried to wrap it in a Box component or changing the style lnline with: style={{padding: 10}} and can't seem to make a…
Dan G.
  • 529
  • 8
  • 21
0
votes
1 answer

Display Field in Edit Form

Currently, if I try to place a Field into an Edit form, the field doesn't display at all. There is no errors in the console or the terminal about why it wont. Example:
Navos
  • 47
  • 7
0
votes
1 answer

How can I get correct typing on handleSubmitWithRedirect when making custom SaveButton?

I need a save button that is visually so different from the normal one, that I opted to build my own based on the SaveButton source code (as suggested in [1]). However, just an import of the component cause the handleSubmitWithRedirect prop to…
larsivi
  • 1,485
  • 10
  • 16
0
votes
1 answer

React Admin: Dynamic SuccessMessage in Create/Edit Views

I am using the react-admin framework, and trying to send a dynamic successMessage from the Create/Edit views based on the value of a child input in the parent view's SimpleForm. Right now GetSuccessMsg() is called once on render and is only passing…
HarshMarshmallow
  • 1,007
  • 11
  • 23
0
votes
0 answers

How do we set the entire form data as a hidden input field value in reactJS (using react-json-schema-forms, react-admin)

We are using JSON Schema to Form library to embed a form inside a reactJS page. We want to set the form (generated from JSON schema) data into a input hidden value to be used later on to pass to a service to save the form value in the database. e.g.…
0
votes
1 answer

React Admin: useDataProvider inside a Redux Saga

I have custom react-admin pages that often query multiple resources (account, posts, comments for the same page). I am using redux sagas to handle API requests as side-effects while decoupling my view component from this logic. Since react-admin…
ilaif
  • 348
  • 2
  • 13
0
votes
1 answer

Save data to two different resources

I'm trying to save a user's full record, but I depend on two separate tables. Profile data is saved in one resource, and the address in another. How can I write the code so that it saves the profile first, and from the generated id, save the…
0
votes
1 answer

Use a ReferenceField inside of an ArrayInput/SimpleFormIterator

As the title says. I need to use a ReferenceField inside of a ArrayInput/SimpleFormIterator. I keep getting the following error: TypeError: Cannot read property 'replace' of undefined Versions: react-admin: 3.2.3 react: 16.12.0 Here is a snippet…
0
votes
1 answer

ReferenceManyFields (One to Many Relationship)

I am working on a project where I have to create one to many relationships which will get all the list of records referenced by id in another table and I have to display all the selected data in the multi-select field (selectArrayInput). Please help…
Amit Kumar
  • 169
  • 1
  • 10
0
votes
1 answer

MSAL and React-Admin integration

How do I integrate MSAL with React-Admin properly. I used the code provided by Microsoft and put it in the Constructor in App.js and it works fine using a redirect method, except that I keep getting a default React-Admin login screen for split…
Alex1844
  • 313
  • 2
  • 8
0
votes
1 answer

Best way to disable edit on lines (via ArrayInput/SimpleFormIterator)?

I have a working solution but it seems a bit slow and buggy, specifically getting in the way of CSS animations when a line is dropped. I'm wondering if the RA team or experienced users have a more elegant, optimal solution. In the future, I hope the…
0
votes
1 answer

ReferenceInput Select Input for Filter component Form

I built a custom Filter component for my List View and Im having trouble populating a Select Input of ALL available options for a property. for instance
{({ handleSubmit }) => ( …