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

[Select] 支持传递value的类型 #2426

Open
xmsz-stu opened this issue Aug 19, 2024 · 0 comments
Open

[Select] 支持传递value的类型 #2426

xmsz-stu opened this issue Aug 19, 2024 · 0 comments
Labels
feature request Request new feature

Comments

@xmsz-stu
Copy link

Which Component Need Enhancement 期望新增功能的组件

  • Select

What does the proposed API look like 期望支持的API

<Select<string>
   value?: string;
   onChange?: (value?: string) => void
 />

Feature Description 功能描述

因为如果不传递string类型,则value的值是'string | number | any[] | Record<string, any> | undefined
然后一般比如传递onChange的时候都是, (value?: string) => void ,现在就会遇到

 Type 'Dispatch<SetStateAction<string | undefined>>' is not assignable to type '(value: string | number | any[] | Record<string, any> | undefined) => void'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'string | number | any[] | Record<string, any> | undefined' is not assignable to type 'SetStateAction<string | undefined>'.
      Type 'number' is not assignable to type 'SetStateAction<string | undefined>'.

必须写成

<Select onChange={(v) => onChange(v as string)}/>

非常麻烦,每次都得写一个

Additional information 补充说明

@xmsz-stu xmsz-stu added the feature request Request new feature label Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request new feature
Projects
None yet
Development

No branches or pull requests

1 participant