【发布时间】:2018-09-10 10:27:34
【问题描述】:
我看到了这个话题You must pass a component to the function returned by connect. Instead received 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);
【问题讨论】:
-
你确定
import TodoForm from '../Components/TodoForm/TodoForm'的路径是正确的