Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Not Rendering Component From Iterated Array in JSX

I have a project variable which follows this structure:

[
    org_id_1: {
        project_id_1: {
            title: ...
        },
        project_id_2: {
            title: ...
        }
    },
    org_id_2: {
        ...
    }
]

In my JSX, I want to display a ProjectCard component for each extracted project. I successfully loop through this structure to each individual project, but the component does not render. My code:

<div className='flexbox...'>
    {
        projects && Object.keys(projects).map(organisationId => {
            const projectsArray = projects[organisationId]
            projectsArray.map(project => {
                return <ProjectCard key={project.id} project={project} />
            })
        })
    }
</div>

I know for sure that I’m iterating through the projects because when I console.log(project), or console.log(project.title) just before the return statement, I can see the correct values show up.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try returning the outer map as the inner scope has a correct return but the outer one isn’t returning anything

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading