Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 类型无效--需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:object_Reactjs_Typescript_Typeahead - Fatal编程技术网

Reactjs 类型无效--需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:object

Reactjs 类型无效--需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:object,reactjs,typescript,typeahead,Reactjs,Typescript,Typeahead,警告:React.createElement:类型无效--应为字符串(对于内置组件)或类/函数(对于复合组件),但应为Get:object 这是前面提到的组件: <Typeahead id={this.props.name} name={this.props.name} onChange={this.changeHandler} onBlur={this.onBlurHandler} onInputChange={this.in

警告:React.createElement:类型无效--应为字符串(对于内置组件)或类/函数(对于复合组件),但应为Get:object

这是前面提到的组件:

 <Typeahead
      id={this.props.name}
      name={this.props.name}
      onChange={this.changeHandler}
      onBlur={this.onBlurHandler}
      onInputChange={this.inputChangeHandler}
      options={this.state.typeAheadOptions}
      placeholder={'Type for ' + this.props.label}
      selected={this.state.selected}
    />

在另一个组件和代码中使用上述组件是:

    <ContTypeAhead
      label="Autex"
      name="autex"
      id="autex"
      size="6"
      options={[]}
      url="settlements/getAutex"
      selected={this.state.autex}
      changed={this.autexChangedHandler}
      wrongSelectionHandler={this.wrongTypeAheadSelectionHandler}
      rightSelectionHandler={this.rightTypeAheadSelectionHandler}
    />;

使用带有CRA的TypeScript。将道具和每个字段的状态接口定义为:任意

您忘记将您的
ContTypeAhead
声明为
功能。
const ContTypeAhead=props=>{

或者。
类。
类ContTypeAhead扩展组件{


或者您不返回()

这是一个非常烦人的问题,但我解决了它。错误背后的原因是,
Typeahead…
,因此我们必须首先在最新版本的Typeahead中包含
@types
。清楚地检查使用的键,因为在新版本中,Typeahead中没有“name”一部分。与日历相同。因此导致了问题。删除这些键解决了问题


谢谢!

事实上这两个东西都有,即使我已经安装了@types/…问题仍然存在。哦..你能提供ContTypeAhead的完整代码吗?