I have 2 objects in this.state of the same component:
Object 1 is a set of key: value pairs.
Object 2 is an array of objects. Each inner object contains again pairs of key: value, but one of the pairs should refer to value stored in the first object:
this.state = {
Object 1: {
key 1: 1,
key 2: 2,
key 3: 3
},
Object 2: [
{
key 1: "...",
key 2: value of e.g. Object 1 - key 3
},
{
...
}
]
};
Is there a way to refer directly to the first object from the second? The only other way that came on my mind was passing the first object as props to another class, but that would be a bit impractical as this is the top element that would ideally contain both objects.
I don't want to store all values in the same object as both objects are rendered in different elements.