How to update objects nested in React state

I have a function that updates my nested objectin React state, and i have a working solution, but im looking for something more polished.

so this is my state structure:

state: {   ...someState,   object: [       {         key1: "1",         key: "2",         key3: "3",         key4: "4"},{         key1: "1",         key: "2",         key3: "3",         key4: "4"}] } 

Currently im using this function to update the state:

handleInputChange = (     e: ChangeEvent<HTMLInputElement>,     name: FilterKeys,     subname?: any,     index?: number   ) => {     e.persist();        if (subname && index !== undefined) {         let prop: SomeKeys;         prop = subname;         const editedObject = Object.assign({}, this.state.object);         editedObject[index][prop] = e.target.value;         const object = Object.keys(editedObject).map((e: any) => {           return editedObject[e];         });         this.setState(           (prevState: I) => ({             ...prevState,             object           }),           () => {             this.someCallback()           }         );      }   }; 

My goal is to do something like this:

 handleInputChange = (     e: ChangeEvent<HTMLInputElement>,     name: FilterKeys,     subname?: any,     index?: number   ) => {     e.persist();        if (subname && index !== undefined) {         let prop: SomeKeys;         prop = subname;         this.setState((prevState)=>{           object: [...prevState.object, prevState.object[index][prop]:3] }) }      }   }; 

I hope you understand what im getting at. I am also aware of a solution where i could assign some key to the object, so i can access it that way, but i was interested in syntax like this, cause imo it looks much cleaner