I want to fetch a state's value, but the problem is that I am receiving state's name in a parameter.
Is there any way to do it directly? (Similar to what is represented in image)
CodePudding user response:
You have to use the variable in brackets like shown below:
function SampleFunc(name){
const ddlValue = this.state[name]
}