I need to push a new object into the state variable without getting the previous values removed. My state is
this.state = {
files:{
file1:
{
user1:[{
key1: val1,
key2: val2,
key3: val3
},
{
key1: val1,
key2: val2,
key3: val3
}
]
}
}
}
I need to update the files as
files:{
file1:
{
user1:[{
key1: val1,
key2: val2,
key3: val3
},
{
key1: val1,
key2: val2,
key3: val3
}
]
},
file2:
{
user2:[{
key1: val1,
key2: val2,
key3: val3
},
{
key1: val1,
key2: val2,
key3: val3
}
]
}
}
I need to push a new object file2 into the state having values in the same structure as file1. How can I update the state with these two objects?