question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating when the App component is included in a Route does not trigger a PUT request

See original GitHub issue

What you were expecting: Saving on the edit component view should trigger a PUT request.

What happened instead: No PUT request is triggered. Moreover:

  • with or without undoable={false}, the undo popup does not show
  • the request seems to be queued and can be triggered by asking a deletion

Steps to reproduce:

See the CodeSandbox https://codesandbox.io/s/great-goldstine-h2u1n

  1. Click on one of the rows
  2. Update it and save it
  3. Notice how no undo popup shows
  4. Delete the ressource
  5. Notice that the previous update is triggered with the query

Related code:

// in src/index.js
/* eslint react/jsx-key: off */
import React from "react";
import { Admin, Resource } from "react-admin"; // eslint-disable-line import/no-unresolved
import { render } from "react-dom";
import Layout from "./Layout";
import posts from "./posts";
import jsonServerProvider from "ra-data-json-server";
import { BrowserRouter as Router } from "react-router-dom";
import { Route, Switch } from "react-router-dom";

render(
  <Router>
    <Switch>
      <Route
        path="/"
        exact
        component={() => (
          <Admin
            dataProvider={jsonServerProvider(
              "https://my-json-server.typicode.com/typicode/demo/"
            )}
            title="Example Admin"
            layout={Layout}
          >
            {permissions => [<Resource name="posts" {...posts} />]}
          </Admin>
        )}
      />
    </Switch>
  </Router>,
  document.getElementById("root")
);


// in src/post.js
import React from 'react';
import {
    Datagrid,
    Edit,
    List,
    SimpleForm,
    TextField,
    TextInput,
} from 'react-admin';

export const PostList = props => (
    <List {...props}>
        <Datagrid rowClick="edit">
            <TextField source="id" />
            <TextField source="title" />
        </Datagrid>
    </List>
);

export const PostEdit = (props) => (
    <Edit {...props}>
        <SimpleForm>
            <TextInput disabled label="Id" source="id" />
            <TextInput source="title" />
        </SimpleForm>
    </Edit>
);


Other information:

Environment

  • React-admin version: 3.2.2
  • Last version that did not exhibit the issue (if applicable): before v3
  • React version: 16.12.0
  • React REST Data Provider version: 3.2.2
  • Browser: observed on firefox and chrome
  • Stack trace (in case of a JS error): /

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
7hibaultcommented, Feb 19, 2020

Thanks for taking the time to look into it.

However it seems to me that this is an important feature for users who want to include react-admin in another redux application. If you already have an app in which you want to include react-admin, there’s a great chance that this app uses react router. If so, how are you supposed to do it?

1reaction
fzaninottocommented, Feb 19, 2020

OK, so the problem comes from including the react-admin app in another Router. This is not supported by react-admin. If you manage to make it work, great! Otherwise, it’s not something we want to spend time on, so I’ll close this issue.

As a side note, maybe sharing the history between your router and the react-admin router will help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component does not remount when route parameters change
When the project component loads, I trigger a data request for that project from the componentDidMount event. I'm now running into an issue ......
Read more >
Angular: Reload/Refresh a Component or Entire Application ...
We have passed true as an argument to reloadComponent(), which implies we want to reload the current route and not navigate to any...
Read more >
How To Handle Routing in React Apps with React Router
In the next step, you'll start connecting routes; for now, render the basic component in your application. Open App.js : nano src/components/App ......
Read more >
Using Angular routes in a single-page application
Update your component with router-outlet link · From your code editor, open the app.component.html file. · Delete the following lines. src/app/app.component.html
Read more >
React Router DOM: How to handle routing in web apps
Editor's note: This React Router DOM tutorial was last updated on 11 ... application to navigate between different components, changing the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found