Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React admin 3.x useDataProvider loading indicator

In version 2.x when you used the hoc withDataProvider and you used the dataProvider injected into the props, you could pass some extra options like onSuccess, onFailure and additionally using that dataProvider made sure all the proper redux actions were called. So you could see the loading indicator and whatnot.

Now with the new hook, you can no longer pass on those options. So you are forced to use also useNotify, useRefresh, etc. I noticed that also no redux actions are being called.... so no loading indicator.

So basically my question is how to use the dataProvider and have it show the loading indicator, but it could be well be paraphrased as have it run all the redux actions that are normally ran when you use the default components like List or View

like image 846
yBrodsky Avatar asked Jun 09 '26 21:06

yBrodsky


1 Answers

When migrating from 2.x to 3.x, you have to migrate your custom data provider. If you had the old kind as specified in 2.x where you used constants:

switch() {
  case MY_CUSTOM_ACTION:
}

Which was used like this:

dataProvider(MY_CUSTOM_ACTION...

This old way keeps working, however the redux actions are not dispatched. Once you migrate into the new way of writing the data provider everything works as expected. https://marmelab.com/react-admin/DataProviders.html#data-providers

like image 65
yBrodsky Avatar answered Jun 11 '26 11:06

yBrodsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!