My state looks like :
this.state = {
service1 : { options: [
{
id:1,
name:"AAAA",
},
{
id:2,
name:"BBB"
},
{
id:3,
name:"CCC"
},
]},
service2: {
options : [
{
id:1,
name:'EEE'
},
]
},
formId:parseInt(this.props.match.params.formId),
wsId:parseInt(this.props.match.params.wsId),
service: this.props.match.params.service, // is string and equals service1 or service2
...
}
in my render, I have this
<Option options={this.state.options} type={'actions'} />
How to telle to my Option component that i want this.state.service1.options or this.state.service2 for example ? knowing that service in my state = 'service1' or 'service2'.
I tested this.state.${this.state.service}.options
but I have an error....
Thanks in advance,