I am new to ReactJS. I used context API to get the data. In my one of the states, I have Object inside Objects.
For Example:-
homeTeamClone: {
"3a21b0a-1223-46-5abe-67b653be5704": {"id":"3a21b0a-1223-46-5abe-67b653be5704","memberName":"Adam"},
"3a21b0a-1223-46-5abe-67b653be5705": {"id":"3a21b0a-1223-46-5abe-67b653be5705","memberName":"Chris"},
"3a21b0a-1223-46-5abe-67b653be5706": {"id":"3a21b0a-1223-46-5abe-67b653be5706","memberName":"Martin"},
}
In another state I hold only keys for reference.
selectedMembers: {
"awayMember":"3a21b0a-1223-46-5abe-67b653be5704", "homeMember":"3a21b0a-1223-46-5abe-67b653be5705"}
Now in component when I tried to display like <div>{homeTeamClone["3a21b0a-1223-46-5abe-67b653be5704"]}</div>
I'm getting an error asking I need to iterate to display the values or use array instead. But I don't want to use array.
Thanks in advance.
question from:
https://stackoverflow.com/questions/65940823/how-to-display-value-using-object-key-and-value-in-reactjs 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…