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

后端 未结 7 2968
梦如初夏
梦如初夏 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 (
        <div className="App">
          ...
          <div>
              <form>
              <SearchBar {...searchBarProps} />
              </form>
          </div>
        </div>
      );
    }
    
    0 讨论(0)
提交回复
热议问题