[Select] 支持传递value的类型
xmsz-stu opened this issue · comments
Chen Shi Jian commented
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)}/>
非常麻烦,每次都得写一个