小编Lon*_*Boy的帖子

使用 React 在 Typescript 中转换错误:“IntrinsicAttributes”类型上不存在属性

我正在使用 Meteor 和 React 构建一个应用程序,Typescript 向我抛出了一个编译错误:

属性 'gameId' 不存在于类型 'IntrinsicAttributes & {} & { children?: ReactNode; }

我有一个组件应用程序,它呈现一个组件游戏,如下所示:

render() {
    return (
       <div className="container">
          {this.state.gameId ? <Game gameId={this.state.gameId} /> : this.renderNewGameButtons()}
       </div>
    );
}
Run Code Online (Sandbox Code Playgroud)

Game是 的扩展React.Component,定义如下。如您所见,我gameIdGameProps界面中定义了一个道具。为什么我仍然收到此错误?

interface GameProps {
  game?: any,
  gameId?: string,
  subscriptionLoading?: boolean,
}

interface GameState {
    isAscending: boolean,
}

class Game extends React.Component<GameProps, GameState> {
  constructor() {
    super();
    this.state = {
      isAscending: true,
    }
  }
  updateGame(game) {
    Meteor.call('games.update', this.props.gameId, game.history, …
Run Code Online (Sandbox Code Playgroud)

meteor typescript reactjs

4
推荐指数
1
解决办法
4838
查看次数

标签 统计

meteor ×1

reactjs ×1

typescript ×1