Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get state's value when state name is in a variable and that variable?

is there a way to use parameter to fetch state's value

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)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to use the variable in brackets like shown below:

function SampleFunc(name){
  const ddlValue = this.state[name]
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading