react-admin
react-admin copied to clipboard
combineDataProviders does not support more than 2 parameters in custom dataProvider methods
What you were expecting:
According to the documentation examples, custom dataProvider methods should not follow the same signature as default methods, in example it's banUser: (userId) => Promise, hence I expect to be able to have any signature that is required for my needs, including functions with more than 2 parameters
What happened instead:
combineDataProviders calls dataProvider methods limiting it to 2 params:
dataProviderMatcher(resource)[name](resource, params)
Steps to reproduce:
- create a custom method in dataProvider
- use combineDataProviders when you attach dataProvider to the admin context
- call a custom method and you will get undefined on 3rd and following parameters.
Related code:
Example on StackBlitz
Here in src/dataProvider.tsx I've created a new method called customMethod with 3rd parameter.
In src/Layout.tsx I call this method and I expect different console.log outputs but always get the falsy one.
Example of this custom method:
// Always falsy
customMethod: (resource, params, optionalFlag) => {
console.log(resource, params, optionalFlag);
if (optionalFlag === true) {
console.log('data provider customMethod optionalFlag is true');
} else {
console.log('data provider customMethod optionalFlag is false');
}
},
Environment
- React-admin version: 4.16.11
- React version: 17
- Browser: Firefox Developer Edition