score:0

you can achieve this by using spread operator. it can be added as follows:

this.setstate({
    file1: [...this.state.file1,{key1:'val1',key2:'val2',key3:'val3'}]
})

score:1

you should use the setstate function expression, so you can access the previous state:

addfile(newfile) {
  this.setstate(state => ({
    files: {...state.files, ...newfile}
  })
}

newfile should be an object that looks like this:

{
  file2: {
    ...
  }
}

this object gets merged into the previous state. if there already was an entry with the same key (file2), it would get overridden.


Related Query

More Query from same tag