在ReactJS中,如何映射处于redux状态的对象项

时间:2017-04-11 09:49:24

标签: reactjs redux react-redux javascript-objects redux-thunk

在ReactJS中,如何映射处于redux状态的对象项?

I want to map "donor" as shown in this pic

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>
  )
                })

                }

1 个答案:

答案 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>
                     )
            })

 }