Reputation: 3
I want to pass props value to inline css.
Here is my code
function Thread(props) {
return(
<div
class="img"
style={{ backgroundImage: "url(Assets/thread-1.webp)" }}
></div>
)}
I want to replace the value image url using {props.ThreadImageUrl}
But I don't know how to write JS inside inline css.
Here is what I want to achieve.
function Thread(props) {
return(
<div
class="img"
style={{ backgroundImage: {props.ThreadImageUrl} }}
></div>
)}
I tried JavaScript string Concatenation but it doesn't work. I'm still newbie to Js and React framework. Glad if someone can help me on this.
Upvotes: 0
Views: 53