在ReactJS中,如何映射处于redux状态的对象项?
const mapStateToProps = (state) => {
console.log("state.donorReducer.donor" ,state.donorReducer.donor)
return {
donorReducer: state.donorReducer,
donorslist: state.donorReducer.donor,
}
}
如何映射捐献者列表项? 我试过了,
{this.props.donorReducer.donor.map((m, i) => {
return(
<div>
<Paper style={style} zDepth={5} >
>Blood: {m.bloodgroup}<br />
>Mobile: {m.mobile}<br />
>Name: {m.fullname}<br />
>Age: {m.age}<br />
>Address: {m.address}<br />
</Paper>
</div>
)
})
}
答案 0 :(得分:1)
您可以简单地在列表上进行映射,然后删除项目
之前的>
符号
{this.props.donorslist && this.props.donorslist.map((m, i) => {
return(
<div>
<Paper style={style} zDepth={5} >
Blood: {m.bloodgroup}<br />
Mobile: {m.mobile}<br />
Name: {m.fullname}<br />
Age: {m.age}<br />
Address: {m.address}<br />
</Paper>
</div>
)
})
}