【发布时间】:2017-07-08 12:53:45
【问题描述】:
下面的代码给出了
未捕获的错误:您必须将组件传递给连接返回的函数。而是收到 undefined
List.js
import React from 'react';
import { connect, bindActionCreators } from 'react-redux';
import PostList from '../components/PostList'; // Component I wish to wrap with actions and state
import postList from '../Actions/PostList' //Action Creator defined by me
const mapStateToProps = (state, ownProps) => {
return state.postsList
}
const mapDispatchToProps = (dispatch) => {
return bindActionCreators({"postsList":postList},dispatch)
}
export default connect(mapStateToProps, mapDispatchToProps)(PostList);
PostList.js
import React from 'react'
export const PostList = (props) => {
return <div>List</div>
}
请帮我解决一下?
【问题讨论】:
-
检查 Postlist 导入
-
PostList导入没有问题
-
您确定不必从'../components/PostList'中导出默认值或导入{PostList};
-
是的。我很确定以这种方式导出足以导入其他任何地方
-
不要那么肯定.. ;)
标签: javascript reactjs redux react-redux