Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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}`/>
like image 469
sod.heretic Avatar asked Jun 03 '26 16:06

sod.heretic


1 Answers

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 :-)

like image 93
Giovanni Panasiti Avatar answered Jun 06 '26 07:06

Giovanni Panasiti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!