相关疑难解决方法(0)

TS2339:'Home'类型中不存在属性'props'

我有一个非常基本的与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克隆这个代码

typescript reactjs

20
推荐指数
2
解决办法
2万
查看次数

与 TypeScript 反应:类型“{}”不可分配给类型

我在 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)

typescript reactjs

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

reactjs ×2

typescript ×2