react-bootstrap-typeahead labelKey 打字稿 [英] react-bootstrap-typeahead labelKey Typescript
问题描述
我在 ericgio 对这个问题的回答中讨论(但从未回答)相同的问题 React AsyncTypeahead using打字稿
labelKey
的类型定义似乎有问题我从这段代码中得到以下错误:
<块引用>
Overload 2 of 2, '(props: TypeaheadProps, context?: any): Typeahead',给出了以下错误.类型 'string' 不可分配给类型 'undefined'.TS2769
依赖:
@types/react-bootstrap-typeahead":^3.4.6",react-bootstrap-typeahead":^5.1.1",
我找到了解决方法!
我将标签与其自己的组件分开,在该组件中,出于某种原因不需要 labelKey.
我不知道为什么会这样,但它对我有用!
I have the same question as discussed (but never answered) in ericgio's answer to this question React AsyncTypeahead using Typescript
There seems to be a problem with the type definitions for labelKey
I get the following error from this code:
<Typeahead
id="basic-typeahead-single"
labelKey="name"
onChange={this.changeEdgeName}
options={this.state.streetNames}
placeholder=""
/>
Overload 2 of 2, '(props: TypeaheadProps, context?: any): Typeahead', gave the following error. Type 'string' is not assignable to type 'undefined'. TS2769
dependencies:
"@types/react-bootstrap-typeahead": "^3.4.6",
"react-bootstrap-typeahead": "^5.1.1",
I found a workaround!
I separated the tag to its own component, in that component the labelKey was not required for some reason.
I have no idea why this works, but it does for me!
这篇关于react-bootstrap-typeahead labelKey 打字稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!