小编Mic*_*ael的帖子

如何在打字稿中为 React-Select 定义 onChange 处理程序

我无法正确输入 onchange 函数。我创建了一个处理函数,但打字稿一直抱怨类型不匹配。

我的功能:

private handleChange(options: Array<{label: string, value: number}>) {
}
Run Code Online (Sandbox Code Playgroud)

打字稿错误:

src/questionnaire-elements/AssessmentFactorSearch.tsx (43,9): Type '{ ref: "select"; name: string; backspaceToRemoveMessage: ""; value: { label: string; value: IAsse...' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Async<OptionValues>> & Readonly<{ children?: React...'. Type '{ ref: "select"; name: string; backspaceToRemoveMessage: ""; value: { label: string; value: IAsse...' is not assignable to type 'Readonly<ReactAsyncSelectProps<OptionValues>>'. Types of property 'onChange' are incompatible. Type '(options: { label: string; value: number; }[]) => void' is not assignable …

typescript react-select

14
推荐指数
2
解决办法
2万
查看次数

标签 统计

react-select ×1

typescript ×1