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.

after delete & redirect from Edit page, react-admin still does a refresh on edit page calling `getOne` on the deleted object

See original GitHub issue

Edit page, undoable is set to false. As soon as we press confirm on Delete, react-admin issues a delete and then a getOne on the deleted record. This causes a rejected promise from the data provider (since the object is not found) which shows an ‘element not found’ popup in react-admin UI. We have a basePath and list view set for redirection and redirection happens, but it seems too late (after the page refresh).

Similarly with undoable set to true, we see a CRUD_GET_ONE action being pushed onto the optimisticCalls array which will issue a getOne after the server sends the response from delete.

There should be a redirect to list page PRIOR to the refresh as in useDeleteWithConfirmController.ts redirect is called before refresh (we do not use our own onSuccess handler). We would expect a getList to be called to refresh list view, not getOne.

const [deleteOne, { loading }] = useDelete(resource, null, null, {
        action: CRUD_DELETE,
        onSuccess: response => {
            setOpen(false);
            if (onSuccess === undefined) {
                notify('ra.notification.deleted', 'info', { smart_count: 1 });
                redirect(redirectTo, basePath);
                refresh();
            } else {
                onSuccess(response);
            }
        }, 

It seems the redirection comes too late. See screenshots:

  1. press the confirm button in Dialog. With breakpoint set on refresh, screen still shows the Edit page while the URL bar already shows the path for the list view.
  2. breakpoint in data provider’s getOne, browser still shows Edit page.
  3. then react-admin shows list view (and it will pop-up the ‘element not found’ notification)

Is there a race condition so redirect does not complete prior to the refresh?
How can we fix this?

React-admin v.3.10.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
Cornul11commented, Jun 23, 2021

I am having the exact same issue, after deleting the record, even if the delete occurred successfully, I still see a getOne request which yields an “Element not found” snackbar.

3reactions
filip-jkcommented, Apr 2, 2021

I’m still experiencing this issue: once the resource is deleted, React Admin redirects me to the List view and fetches the deleted resource with GET_ONE.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does react-admin call getOne after delete, on the deleted ...
The getOne is called because the refresh happens too early, still on the Edit page, before redirection. – Bart007. Nov 18, 2020 at...
Read more >
React-admin - The Create and Edit Views
You can customize the <Create> and <Edit> components using the following props: ... If the dataProvider returns in error, the page is refreshed...
Read more >
marmelab - Bountysource
after delete & redirect from Edit page, react-admin still does a refresh on edit page calling `getOne` on the deleted object $ 0...
Read more >
Configure Hosting behavior | Firebase Hosting - Google
Set up redirects for pages that you've moved or deleted. ... You can find a full firebase.json configuration example (covering only Firebase Hosting)...
Read more >
Client API - NextAuth.js
If you pass redirect: false to signOut , the page will not reload. The session will be deleted, and the useSession hook is...
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