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

Warnings thrown in console when using RadioButtonGroupInput inside ReferenceInput #6074

Closed
JoeJErnst opened this issue Mar 22, 2021 · 1 comment · Fixed by #6139
Closed
Labels

Comments

@JoeJErnst
Copy link

What you were expecting:

No errors or warnings to be thrown. Behavior should be exactly as when using SelectInput inside ReferenceInput. This only appears to be happening when populating the choices via the ReferenceInput. We don't see the messages when hardcoding an array of values in the app. It happens on both the Create and Edit views.

What happened instead:

I get warnings printed in the console, but the App behavior appears to work as it should. (Full stack traces omitted for brevity):

Warning: Failed prop type: The prop `choices` is marked as required in `RadioButtonGroupInput`, but its value is `undefined`.
Warning: React does not recognize the `setFilter` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `setfilter` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
Warning: React does not recognize the `setPagination` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `setpagination` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
Warning: React does not recognize the `setSort` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `setsort` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

Steps to reproduce:
This code works fine:

          <ReferenceInput
            label="Status"
            source="status"
            reference="customerLocationStatuses"
            validate={schema.status}
          >
            <SelectInput optionText="name" optionValue="id" />
          </ReferenceInput>

This code causes the warning stack traces in the console:

          <ReferenceInput
            label="Status"
            source="status"
            reference="customerLocationStatuses"
            validate={schema.status}
          >
            <RadioButtonGroupInput optionText="name" optionValue="id" />
          </ReferenceInput>

Other information:
Both examples refer to the following resource that is defined in the App.js:

...
        <Resource name="customerLocationStatuses" />,
...

It returns data in this format:

{
    "totalCount": 2,
    "resultList": [
        {
            "name": "Active",
            "id": "ACTIVE"
        },
        {
            "name": "Inactive",
            "id": "INACTIVE"
        }
    ]
}

Which is massaged into react-admin's preferred format via a custom dataProvider:

...
export const convertHTTPResponse = (response, type, resource, params) => {
  const { json } = response;

  switch (type) {
    case GET_MANY:
    case GET_LIST:
      return { data: json.resultList, total: json.totalCount };
    case GET_MANY_REFERENCE:
      if (!json.hasOwnProperty("totalCount")) {
        throw new Error(
          "The numberOfElements property must be must be present in the Json response"
        );
      }
      return { data: json.resultList, total: json.totalCount };
    case CREATE:
      return { data: { ...params.data, id: json.id } };
    default:
      return { data: json };
  }
};
...

Environment

  • React-admin version: 3.12.1
  • Last version that did not exhibit the issue (if applicable): N/A
  • React version: 17.0.1
  • Browser: Chrome (latest)
@djhi
Copy link
Collaborator

djhi commented Apr 9, 2021

Reproduced. Thanks

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

Successfully merging a pull request may close this issue.

2 participants