As for the heading: it seems a little bit confusing but it is not.

In React I'm doing re-usability of code

I have

```
state={
       colorObj1: {r:'0',g:'0',b:'0',a:'1'},
       colorObj2: {r:'0',g:'0',b:'0',a:'0'},
       colorObj3: {r:'0',g:'0',b:'0',a:'1'},
       colorObj4: {r:'0',g:'0',b:'0',a:'0'},
       colorObj5: {r:'0',g:'0',b:'0',a:'1'}
      }

```

I want this function --> By Id of Object, I want to set the color to a particular Object. 

id value --> 1,2,3,4,5

```
getSelectedColor=(color,id) => {
    this.setState({colorObj{`id`}: color})  //WRONG CODE
}

```