Rendering JSON into React, a little advice

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.

  "ServiceItem": [
      "projectImage": "cat.jpg",

And I am trying to have it render some JSX with this code

 class ServiceItem extends Component {
     state = { ServiceItem: []
     render() { 
            var ServiceItem ={
              var projectImage = 'public/serviceImages'+ServiceItem.projectImage;
              return <div key={} className="columns service-item">
                 <div className="item-wrap">
                  <a href={ServiceItem.url} title={}>
                     <img  className="projectImage" alt={ServiceItem.title} src={projectImage} />
                     <div className="overlay">
                        <div className="service-item-meta">
         return ( <div>{ServiceItem}</div> );

Since there’s no error message, I am a bit stuck. Any help would be appreciated.
Thank you.

How are you getting to the JSON?

How are you passing it to the component?

If you log do you get the JSON?

Without seeing the full code it’s hard to help. Post a GitHub link or use something like codesandbox to post the code.

Edit: do you really need a class component? I’d suggest using function components when possible and hooks.

1 Like

Thanks for the reply. I think you found my issue without even seeing the full code. I don’t think the JSON is connecting to the JSX, I will work on this.
Thanks for helping me get unstuck

I am having a bit of trouble passing data on to the services component. I am trying to do it as such

<Route path="/services" component={Services} data={this.state.Services.ServicesJSON} />

However you can probably guess that it’s not working as intended.
Here is the github link to the full code, I have rolled back some changes because my code got a little pasta-y
Thanks again.

Did you delete the repo? I can’t find it.

Whoops! Sorry it was private on accident.
And sorry for these late replies, because of this pandemic I am being called in to work all the time and I’m not checking FCC.

1.You have {this.state.resumeData.ServiceItem}, it should be, {this.state.ServiceItems.ServiceItem}

  1. You can’t pass props like you are to the component in <Route> ( Route props)

Here is one way, taken from this page.

  render={props => (
  1. In the Services component it should be not
1 Like

Thank you so much for your continued assistance.
You’ve solved my problem, I hope one day to return the favor to you.