Answer the question
In order to leave comments, you need to log in
How to display img in component props?
There is a component which is used many times. It has text and photos. I understood the text, but not the picture.
The code of the component itself:
function NewSubProject(props) {
return (
<div className="gallery-image">
<div className="img-box">
<img src = { props.ProjectView } />
<div className="transparent-box">
<div className="caption">
<p> { props.ProjectName } </p>
<p className="opacity-low"> { props.ProjectDesc } </p>
</div>
</div>
</div>
</div>
)
}
export default NewSubProject;
<NewSubProject ProjectView = {'http://via.placeholder.com/350x250.png'}
ProjectName = "asd"
ProjectDesc = "123" />
<NewSubProject ProjectView = {'require("../images/github-brands.svg")'}
...
Answer the question
In order to leave comments, you need to log in
props is usually called in camelCase. Instead of ProjectView, the property should be called projectView or generally shortened to view (or img).
<NewSubProject img={require('../images/github-brands.svg')}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question