我正在将现有的应用程序转换为打字稿。由于此错误,我的应用程序将无法编译:
Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttrributes<Component<{ dispatch: any; }
Typescript在App.tsx中的AddTodo组件下面添加了一条波浪形的红线。我对此很陌生,不确定我做错了什么。请帮忙。
App.tsx:
import * as React from 'react'
import Footer from './Footer'
import AddTodo from '../containers/AddTodo'
import VisibleTodoList from '../containers/VisibleTodoList'
const App = () => (
<div>
<AddTodo />
<VisibleTodoList />
<Footer />
</div>
)
export default App
AddTodo.tsx:
import * as React from 'react'
import { connect } from 'react-redux'
import { addTodo } from '../actions'
let AddTodo = ({ dispatch }: {dispatch: any}) => {
let input: any
return (
<div>
<form onSubmit={e => {
e.preventDefault()
if (!input.value.trim()) {
return
}
dispatch(addTodo(input.value))
input.value = ''
}}>
<input ref={node => {
input = node
}} />
<button type="submit">
Add Todo
</button>
</form>
</div>
)
}
export default connect()(AddTodo)