sod.heretic
sod.heretic

Reputation: 126

reactjs semantic ui Image src not working with backticks example( `${myvalue}` )

I am using semantic-ui-react to style and show some components, and I got stuck into the following issue. Usually, I use backticks, and the dollar signs to use the core values of my variables in a link or HTTP address, but when I try to use it on the Item component, it doesn't work. It only accepts simple or double quotes. Any ideas how I can do this? I need to dynamically change the src of the Image every time the user presses a new button.

 <Item.Image src=`http://...../${this.state.card}`/>

Upvotes: 3

Views: 2365

Answers (1)

Giova.panasiti
Giova.panasiti

Reputation: 447

yes this won't work in react. the correct way to do it is:

 <Item.Image src={`http://...../${this.state.card}`} />

This is because `(backticks) only work inside Javascript :-)

Upvotes: 6

Related Questions