我已经尝试了下面链接中的解决方案,但仍然无法解决。我是React和JS的新手。谁能帮我吗。 @@
&
这是减速器
const mapStateToProps = state =>{
return {
data:{
names: state.names,
ages: state.ages,
genders: state.genders
},
};
}; // This is the copy of array in Redux state, it comes from the reducer.
const ConnectedList = ({data})=>(
<ul>
{data.names.map(el => (
<li key={el.id}>{el.data.names}</li>
))}
{data.ages.map(el => (
<li key={el.id}>{el.data.ages}</li>
))}
{data.genders.map(el => (
<li key={el.id}>{el.data.genders}</li>
))}
</ul>
);
const List = connect(mapStateToProps)(ConnectedList);
export default List;
答案 0 :(得分:0)
好吧,我只需要返回数据,而不需要返回数据内部的var ...
const mapStateToProps = state =>{
return {
data: state.data
};
};