Endless loop in Edit after deleting a reference
There is a case where the edit component generates an endless loop of rest requests if a referenced entry wasnt found.
What you were expecting:
No endless loops
What happened instead:
Endless loops
Steps to reproduce:
- Visit the RA demo
- List orders
- Klick the user of the first order
- Delete User
- Go back to the orsers list
- edit the first order
See https://imgur.com/mMxkQZL for a demo
Environment
- React-admin version: 2.1.1
- Last version that did not exhibit the issue (if applicable):
- React version: 16.4.1
- Browser: Chrome
- Stack trace (in case of a JS error): -
Reproduced
This happens in case of broken relationship: the Order tries to fetch the related Customer based on the customer_id, but the server has no such customer.
Note that the cascade delete should be handled server-side. So this is a corner case.
This is a side effect of the onFailure meta on the crudGetOne action. When it fails, it specifies a redirectTo as list which is resolved to the basePath. In the case of the ReferenceInput page, the basePath is somehow null which seems to redirect to the current page possibly leading to a mount/remount of the components
creating infinite loop when i am using <Datagrid rowClick="expand" expand={<DailyReportInfoShow />} optimized> in Edit component. I am using expand two times, once for parent resource and second for child resource .
How to overcome this?
For support question ("How To", usage advice, or troubleshooting your own code), you have two options:
- Community support: Ask your question on StackOverFlow. This makes your question easy to find by the developer community. StackOverFlow has great SEO, gamification, voting, and reputation system.
- Professional support: If you're a React-Admin Enterprise Edition subscriber, you have unlimited access to the Professional Support service. This service guarantees that you'll get an answer shortly.