Hello everyone. I am having a bit of an issue with my project.
I am trying to have a JSON file that contains infomation, and then have it render a JSX element to the page.
Sadly nothing is showing up. If there were an error message I would google it and go at it from there. But there’s no error message, just a blank page where items should be.
My JSON
{
"ServiceItem": [
{
"name":"Yeet",
"description":"Test",
"projectImage": "cat.jpg",
"url":"#"
}
]
}
And I am trying to have it render some JSX with this code
class ServiceItem extends Component {
state = { ServiceItem: []
}
render() {
if(this.props.data){
var ServiceItem = this.props.data.ServiceItem.map(function(ServiceItem){
var projectImage = 'public/serviceImages'+ServiceItem.projectImage;
return <div key={ServiceItem.name} className="columns service-item">
<div className="item-wrap">
<a href={ServiceItem.url} title={ServiceItem.name}>
<img className="projectImage" alt={ServiceItem.title} src={projectImage} />
<div className="overlay">
<div className="service-item-meta">
<h5>{ServiceItem.name}</h5>
<p>{ServiceItem.description}</p>
</div>
</div>
</a>
</div>
</div>
})
}
return ( <div>{ServiceItem}</div> );
}
}
Since there’s no error message, I am a bit stuck. Any help would be appreciated.
Thank you.