In React, can a useState’s value be used in a variable chain? [duplicate]

For example, if I have a useState with the string “drama” set as its value, can I use the useState’s string in the path when accessing data in an object? So console.log(movies[0].drama) would be functionally the same as something like console.log(movies[0].--useStateName--).

Specifically I’ve got an array of movies with each movie having standard data such as title, release date, rating etc. but each movie also has a data point for every possible genre as a boolean, 0 if it is that genre, 1 if it is not.

If I’m trying to console log if the first movie in the array is a drama, I can console.log(movies[0].drama) and it will give ‘1’, because the movie it’s returning is a drama.

Separately from the API, I have an array in the application made up of just the genres as an array of strings, this array has been mapped to a form select input. A useState is being updated with whichever genre is selected in the select input.

So the problem is that I need to be able to use the string saved in the useState when checking for movies that belong to whichever genre is in the useState at the time. So if the useState is the string “drama”, I need to be able to do something like console.log(movies[0].<useStateName>) and have it do the exact same thing as console.log(movies[0].drama).