我有一个非常基本的与tsx反应的程序,我收到一个错误,我无法弄清楚为什么
import React from 'react';
// import {connect} from 'react-redux'
export class Home extends React.Component {
render(){
console.log(this.props)
return (
<div>Working</div>
)
}
}
import * as React from 'react'
import * as ReactDOM from 'react-dom';
import {Home} from './Components/Home.component'
class App extends React.Component<any,any>{
render(){
return(
<Home value="abc" />
)
}
}
ReactDOM.render( <App />, window.document.getElementById("app"))
Run Code Online (Sandbox Code Playgroud)
git克隆这个代码
我在 React 中有一个组件,它显示基于 prop 的导航。当我尝试运行应用程序时,我无法弄清楚为什么会出现此错误:
(19,8): Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TableSystems> & Readonly<{ children?: ReactNode; }...'.
Type '{}' is not assignable to type 'Readonly<{ todos: any; showNav: boolean; }>'.
Property 'todos' is missing in type '{}'.
Run Code Online (Sandbox Code Playgroud)
我的组件看起来像这样:
import * as React from 'react'
import Navigation from '../components/Navigation'
import TableSystems from '../components/TableSystems'
class SystemTable extends React.PureComponent<{showNav: boolean }> {
render(){
return (
<div >
<div >
<div className="navigationContainer">
<Navigation {...this.props.showNav} className="sideMenu"/>
<TableSystems/>
</div>
</div>
</div>)
} …Run Code Online (Sandbox Code Playgroud)