我正在使用 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,定义如下。如您所见,我gameId在GameProps界面中定义了一个道具。为什么我仍然收到此错误?
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)