Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes

后端 未结 7 2970
梦如初夏
梦如初夏 2020-12-15 02:42

i am currently making a simple react application. this is my index.tsx

import * as React from \'react\';
import * as ReactDOM from \'react-dom\         


        
7条回答
  •  粉色の甜心
    2020-12-15 03:12

    I solved a lot of "not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes" type of errors (Microsoft closed issue) just by declaring an object that is passed entirely to the component.

    With the OP's example, instead of using term={this.props.term}, use {...searchBarProps} to get it working:

    render() {
      const searchBarProps = { // make sure all required component's inputs/Props keys&types match
        term: this.props.term
      }
      return (
        
    ...
    ); }

提交回复
热议问题