Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combineDataProviders does not support more than 2 parameters in custom dataProvider methods #9675

Closed
karpushchenko opened this issue Feb 20, 2024 · 1 comment · Fixed by #9676

Comments

@karpushchenko
Copy link

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
@fzaninotto
Copy link
Member

Fixed by #9676

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants