Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
JS Component will not display on page?

My component will not display on the page. There are no errors or any other warnings/messages. I console log the value of gameData and all the data is as it should be. Here's the exported function:

export default function AllGameDeals( gameData ){

    const dealArr = new Array()

    const deals = () => {
        gameData.deals.map((deal) => {
            const imageSrc = `https://www.cheapshark.com/img/stores/icons/${(parseInt(deal.storeID)-1)}.png`
            deal.imageSrc = imageSrc
            dealArr.push(deal)
        })
        return dealArr
    }
    deals()

    return (
        <div>
        {dealArr.forEach(gameDeal => (  
          <Box
                key={gameDeal.dealID}
                display={{ md: "flex" }}
                boxShadow="dark-lg"
                p={4}
                >
                <Box flexShrink={0}>
                    <Image borderRadius="lg"
                        width={{ md: 40 }}
                        height={{ md: 20 }}
                        src={gameData.info.thumb}
                        alt={gameData.info.title} />
                </Box>
                <Box>
                    <Image
                        src={gameDeal.imageSrc}
                        alt={gameDeal.storeID} />
                </Box>
                <Box>
                    <Text>{gameDeal.price}</Text>
                    
                </Box>
                </Box>
        ))}
        </div>
        
    )
    
}

I feel like I am missing something very obvious...

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try changing from dealArr.forEach to dealArr.map.

The reason is that .forEach returns nothing, but .map returns an array.

about 4 years ago · Juan Pablo Isaza Report

0

You should be using .map instead of .forEach because .forEach doesn't actually return a value

Other possible improvements:

  1. Use useEffect to fetch data on mount of the component (instead of fetching everytime)
  2. Use useState to "persist" your state within the component
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!