0

I am just learning Redux, and have run into the following difficulty. The state object mylist looks like this:

{
  byId : {
    1 : {
      id : 1,
      name : "hello"
    },
    2 : {
      id : 2,
      name : "goodbye"
    }
  },
  allIds : [ 1, 2 ]
}

My component is trying to iterate the state like so:

<select>
 {this.props.mylist.allIds.map(function(x){
    return <option key={x} value{x}>
             {this.props.mylist.byId[x].name}
           </option>
 })}
</select>

The value of x is being pulled out successfully by the map function. But this.props.mylist.byId[x].name is not resolving.

Am I doing something wrong here?

James Young
  • 1,372
  • 13
  • 16

0 Answers0