Question: I have a react app in which i need to push new key values (values can be arrays) to a key in state.

```
this.state = {
    keyValue: {}
}

```

Visualising it will be something like this:

`keyValue:{'key1':[value1],'key2':[value2,value3]}`

How do i do this in react ?i tried:

`const newKeyvalue = Object.keys(state.keyValue).map((keyValues) => {
return {...keyValue, key: value};});
this.setState({keyValue: newKeyvalue});`
But this does not work

Answer: 
`keyValue` is a dynamic variable? 
They try the following 

```
this.setState({[keyValue]: newKeyvalue});

```
You can do this by following statement.

```js

  const obj = {'keyValue':{'key1':[1],'key2':[2, 3]}}
  const newKeyValue = Object.assign({}, obj.keyValue, {"key3":[6,7], "key2": [...obj.keyValue.key2, 8]})
  console.log(newKeyValue);
```