Josh Winters
Josh Winters

Reputation: 855

concatenate two variables in react

I am currently mapping over data, and I want to concatenate 2 variables together.

For example:

<img src={image path}{image name from .map} />

So the question is, how do i combine these both into one?

Upvotes: 0

Views: 937

Answers (2)

Asif Khan
Asif Khan

Reputation: 56

use back tack for example

<img src={`${image path}${image name from .map}`} />

Upvotes: 1

ramirozap
ramirozap

Reputation: 1459

there are a lot of ways to do it, one could be with string literals interpolation:

<img src={`${variable1}${variable2}`}/>

Upvotes: 4

Related Questions