react-admin: View and edit crash when reload page or press F5

Hello everyone!

When i refresh the page, edit or view with simpleform this can’t load the fields.

What you were expecting:

Fields are load when access for button edit in the list.

image

What happened instead:

Fields are not load when refresh the page with F5. image

Related code:

My app component
class App extends Component {
  render() {
    const dataProvider = jsonServerProvider('', httpClient); //delete the address for obvious reasons

    return (
      <Admin customRoutes={customRoutes}  layout={MyLayout} theme={theme} title="TRALE" dashboard={Dashboard} dataProvider={dataProvider} authProvider={authProvider} i18nProvider={i18nProvider}>
        {permissions => [
          
          // Restrict access to the edit and remove views to admin only
          <Resource name="empresas_desplegable" />,
          <Resource options={{ label: 'Camiones' }} name="camiones" list={CamionesList} create={CamionesPost} edit={CamionesEdit} icon={CamionesIcon} />,
          <Resource options={{ label: 'Semirremolques' }} name="semirremolque" icon={CamionesIcon} list={SemirremolquesList} create={SemirremolquesPost} edit={SemirremolquesEdit} />,
          <Resource options={{ label: 'UsuariosApp' }} name="usuariosapp" icon={UsuariosIcon} list={UsuariosAppList} create={UsuariosAppPost} edit={UsuariosAppEdit} />,
          <Resource options={{ label: 'Viajes' }} name="servicios" edit={ViajesEdit} show={ViajesShow} icon={ViajesServicios} list={ViajesList} create={CrearViaje} />,
          <Resource options={{ label: 'Productos' }} name="productos" edit={ProductosEdit} icon={ProductosIcon} list={ProductosList} create={ProductosPost} />,
          
          // Only include the categories resource for admin users
          permissions === 'superadmin'
            ? <Resource options={{ label: 'Empresas' }} name="empresas" icon={Business}  list={EmpresasList} edit={EmpresasEdit} create={EmpresasPost} />
            : null,
          permissions === 'superadmin'
            ? <Resource options={{ label: 'UsuariosWeb' }} name="usuariosweb" list={UsuariosList} icon={UsuariosIcon} create={UsuariosPost} edit={UsuariosEdit} />
            : null,
          permissions === 'superadmin'
            ? <Resource options={{ label: 'Clientes' }} name="clientes" icon={UsuariosIcon} list={ClientesList} create={ClientesPost} edit={ClientesEdit} />
            : <Resource options={{ label: 'Clientes' }} name="clientes" icon={UsuariosIcon} list={ClientesList} />,
          permissions === 'superadmin'
            ? <Resource options={{ label: 'Destinos' }} name="destinos" icon={DestinosIcon} list={DestinosList} create={DestinosPost} edit={DestinosEdit} />
            : <Resource options={{ label: 'Destinos' }} name="destinos" icon={DestinosIcon} list={DestinosList} />,

        ]}

      </Admin>
    );
  }
}

export default App;

My edit component. This issue is in all edit and view components that i have in the app.

import React, { Component } from 'react';
import { TextInput, SimpleForm, Edit, BooleanInput, required } from 'react-admin';
import ThumbUp from '@material-ui/icons/ThumbUp';

class EmpresaEdit extends Component {
    render() {
        return (
            <Edit {...this.props}>
                <SimpleForm>
                    <TextInput source="nombre" validate={[required()]} />
                    <TextInput source="rut" validate={[required()]} />
                    <TextInput source="telefono" validate={[required()]} />
                    <BooleanInput
                        source="habilitado"
                        checked={true}
                        options={{
                            checkedIcon: <ThumbUp />,
                        }}
                    />
                </SimpleForm>
            </Edit>
        );
    }
}

export default EmpresaEdit;

Environment

  • React-admin version: 3.1.1
  • React version: "^16.12.0
  • Browser: Chrome

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Okay, I will create a codesandbox, give me a day

Then maybe you could create a codesandbox reproducing the issue? Without a way to reproduce it, we’ll close the issue

https://codesandbox.io/s/confident-snowflake-u8f03?file=/src/posts.js

I have created the demo for your reference, url end point /booking and edit on first record then try to reload the browser, it do not update the values only blank screen appears. It would be really helpful.