Paweł Pierzchlewicz
Head of Artificial Intelligence

10 min read

August 7, 2020

Getting Started: React Admin

What will you learn

Our shared need for precision, fair play, and heightened tension during matches shapes a willingness to incorporate new sports technologies.

  1. Moreover, this technological enhancement adds a layer of suspense and anticipation.
  2. Intensifying the drama of each match and contributing to a new dimension in our evolving sporting landscape.
  3. Moreover, this technological enhancement adds a layer of suspense and anticipation.
  4. Intensifying the drama of each match and contributing to a new dimension in our evolving sporting landscape.

At Teacode.io we come across the need to provide administrative technology on a daily basis. However, knowing that admin panels are not the actual money-maker for our clients we had to embark on a quest to find a solution that allows fast development while maintaining full customizability.

On our journey through different frameworks, we came upon one that could just have the golden ratio between development time and personalisation. It’s React Admin! Let me show you why and get you rolling with it.

What is 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.”

In other words, it is an easy-to-use React.js framework with the goal of cutting down on the time required to deploy an admin dashboard for your application.

By providing a variety of out of the box components it allows one to build a fully functional admin panel in little or even no time. Furthermore, it is fully customisable, hence however fancy your needs would be react-admin will not be limiting you.

There will also be no need for sacrifice in the looks! The components are built using the Material UI package, which have one of the most fashionable designs out there.

Adding extra functionality is a piece of cake with the use of Redux and Saga that are neatly integrated into react-admin.

So… Let’s dive into the basic setup!

By clicking this button you agree to receive information from TeaCode about software development and app marketing, the company and its projects to your email. Your data is processed by TeaCode (Postępu 15, 7th floor, 02-676 Warsaw, Poland) to send you relevant content via newsletter (from which you can unsubscribe at any time). You can read more in our Privacy Policy.

Setup

1npx create-react-app admin-app
2cd ./admin-app
3npm install --save react-admin
1import React, { Component } from 'react'
2import {Admin, Delete, Resource} from 'react-admin'
3
4import jsonServerProvider from 'ra-data-json-server'
5
6import { PostList } from './posts'
7
8class App extends Component {
9
10  render () {
11    return (
12      <Admin
13        dataProvider={jsonServerProvider('http://jsonplaceholder.typicode.com')}
14      >
15        <Resource
16          name="posts"
17          list={PostList}
18        />
19      </Admin>
20    )
21  }
22}
23
24export default App
1import React from 'react'
2import {
3  List,
4  Datagrid,
5  TextField,
6  EditButton,
7  SimpleForm,
8  TextInput,
9  LongTextInput,
10  Edit,
11  DisabledInput,
12  Create,
13  DeleteButton
14} from 'react-admin'
15
16export const PostCreate = (props) => (
17  <Create {...props}>
18    <SimpleForm>
19      <TextInput source='title' label='Title' />
20      <LongTextInput source='body' label='Body' />
21    </SimpleForm>
22  </Create>
23)
24
25export const PostEdit = (props) => (
26  <Edit title='Post Edit' {...props}>
27    <SimpleForm>
28      <DisabledInput label='id' source='id' />
29      <TextInput source='title' label='Title' />
30      <LongTextInput source='body' label='Body' />
31    </SimpleForm>
32  </Edit>
33)
34
35export const PostList = (props) => (
36  <List {...props}>
37    <Datagrid>
38      <TextField source='id' />
39      <TextField source='title' label='Title' />
40      <EditButton />
41      <DeleteButton />
42    </Datagrid>
43  </List>
44)
1<Resource
2  name='post'
3  list={PostList}
4  remove={Delete}
5  edit={PostEdit}
6  create={PostCreate}
7/>

Result

Customisability

Now that we have dealt with the basics we can have a quick look at the customisability of react-admin. As all the components provided are built around basic react concepts it is simple to add your own elements to it. It is important to remember that react-admin provides components, which are just that, not a magical creature that only works with itself.

The admin component has built-in handling for custom routes, redux reducers and sagas. What is more building custom fields and inputs is just simply creating a component that is a Redux-Form field or that will display some data. A quick tutorial on how to integrate the components with the data is available in the documentation.

Hopefully with the help of this article, you should be able to meet your administrative needs. However, should you require a more sophisticated interface I would highly recommend familiarising with the documentation.

Try react-admin for yourself and enjoy or choose TeaCode to do it for you!

Table of Contents:

Similar articles:

Subscribe to our newsletter