Answer the question
In order to leave comments, you need to log in
How to properly set the style attribute in React?
I have a problem,
there is a component in which an image should be placed on the background of the block through the style attribute, the image should be transferred to the component by props from top to bottom. I implemented approximately according to the documentation, but there is simply no picture!
import React from 'react';
import Button from './Button'
export default function Post(props){
const postImage ={
background: 'url(' + props.img + ') no-repeat center top/cover'
};
return(
<div className="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div className="post__item" style={postImage}>
<div className="descr">
<p className="post__title">{props.title}</p>
<Button className="button">Open</Button>
<div className="post__descr">
{
props.descr
}
</div>
</div>
</div>
</div>
);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question