How to use JXS within html elements' attributes' double quotes as we use in PHP?

Viewed 46

So in php if we want to refer to a source of an image, we can do it like this

<img src="images/<?php $imageName; ">" />

But in JSX of react, we can only do like

<img src={image.path} />

But since I have only stored the name of the image, I need to do something like this

<img src="images/{image.name}" />

I do know that image.name is a string rather than a variable as in PHP. But is there a way to make this write?

NOTE: I cannot create a constant string too since that should be written in this.something.map(smth => "I am wriitng it here")

1 Answers

You can try:

<img src={`images/${image.name}`} />
Related