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

SelectInput throw choices type error after upgrade to v4 #7593

Closed
bingluen opened this issue Apr 27, 2022 · 1 comment
Closed

SelectInput throw choices type error after upgrade to v4 #7593

bingluen opened this issue Apr 27, 2022 · 1 comment
Labels

Comments

@bingluen
Copy link
Contributor

bingluen commented Apr 27, 2022

After upgrade to v4, SelectInput throw type error: Type '{ name: string; value: number; }[]' is not assignable to type 'RaRecord[]'. Property 'id' is missing in type '{ name: string; value: number; }' but required in type 'RaRecord'.

What you were expecting:

The choices is not limited RaRecord[] type .

What happened instead:

The prop choices of SelectInput is limited to RaRecord[]

Steps to reproduce:

  1. Create an array of non special structure object as choices. But not include id as key for each choices
  2. pass this array as SelectInput choices
  3. throw Type Error during build.

Related code:

const choices = [{ name: 'first', value: 100 }, { name: 'second', value: 200}]

<SelectInput
  label="order"
  source="order"
  optionText="name"
  optionValue="value"
  choices={choices}
/>

Other information:

Environment

  • React-admin version: v4
  • React version: 17.0.2
  • Browser: edge 100
@fzaninotto
Copy link
Member

Thanks for the report, choices should indeed ne any[]. Would you like to open a PR to solve this?

@fzaninotto fzaninotto added the bug label Apr 27, 2022
@slax57 slax57 closed this as completed in a2ca057 Apr 28, 2022
slax57 added a commit that referenced this issue Apr 28, 2022
…ut-should-indeed-be-any

Fix #7593, choices should indeed be `any[]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants