Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force GET_ONE request when navigating to Show page

Tags:

react-admin

As I believe is common in many APIs, ours returns a subset of fields for a record when it is part of a List request, and more details when it is a single-record request to its Show endpoint.

It seems that react-admin attempts to avoid doing a second request when loading a Show page (possibly re-using the record data from List?), which results in missing data. Refreshing the page fixes this, but I'm wondering if there is a setting that will force a GET_ONE request on every Show page load.

like image 239
swrobel Avatar asked Jul 19 '18 19:07

swrobel


1 Answers

There are no setting for that. However, this should be achievable with a custom saga which would listen to LOCATION_CHANGE action (from react-redux-router) and dispatch a refreshView action (from react-admin) when the new location pathname ends with /show.

Edit: however this is very strange. We only use the data we already got from the list for optimistic display but we still request with a GET_ONE when navigating to a show page from the list. Do you have a codesandbox showing your issue?

like image 174
Gildas Garcia Avatar answered Nov 09 '22 10:11

Gildas Garcia