I follow this example about redux
but I write with TypeScript.
https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/todos-with-undo
I get trouble in AddTodo.tsx
file.
import * as React from 'react'
import { connect } from 'react-redux'
import { addTodo } from '../actions'
const AddTodo = ({ dispatch }) => {
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>
)
}
AddTodo = connect()(AddTodo)
export default AddTodo
The dispatch
parameter does not allowed. The error says:
[ts] Binding element 'dispatch' implicitly has an 'any' type.