我看到这个话题你必须将一个组件传递给connect返回的函数。而是收到 undefined,但这与我的情况无关。
所以,我无法理解我的演示文稿/容器连接有什么问题?
我将它们彼此连接起来,但出现错误: You must pass a component to the function returned by connect. Instead received undefined
/* 零件 */
import React from 'react';
import AddTodo from '../../Actions/AddTodo'
import TodoFormAdd from '../../Containers/TodoFormAdd'
class TodoForm extends React.Component{
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(e) {
e.preventDefault();
document.querySelector('input').input.value = '';
TodoFormAdd(this.props.store, this.input.value);
}
render() {
return (
<form id="tp" onSubmit={this.handleSubmit}>
<input type="text" placeholder="Your text" />
<button type="submit">Add todos</button>
</form>
);
}
}
export default TodoForm;
/* 容器 */
import { connect } from 'react-redux';
import TodoForm from '../Components/TodoForm/TodoForm'
import AddTodo from '../Actions/AddTodo'
let TodoFormAdd = (store, input) => store.dispatch(AddTodo(input));
export default connect(TodoFormAdd)(TodoForm);