How pass hyphen inside a curly braces in react js

Viewed 27

`

<img src={poster.poster-image} alt="poster 1" class="h-28 w-28" />

` poster-image is coming from api but iam getting an error saying image is not defined. how to fix this?

1 Answers

poster.poster-image is a subtraction expression (i.e. poster. poster - image).

To access a key that contains characters that cannot appear in an identifier, use brackets:

poster["poster-image"]

Related