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

230
Views
How to Fill Empty Properties in a Table Using Map Method in React

I am trying to make a table using Map Method in React. My table is consisted of div tag, due to difficulty of handling table tag. So far, I have almost finished making a table shape, but each row has a different quantity of properties.

Row with different quantity of properties

I would like to fill the table, even if some rows don't have properties. I thought I could map-base on the longest row, but I'm having trouble with it. Is there any way of filling empty properties in a table?

My code:

  {refinedData && !isEmpty
          ? Object.entries(refinedData).map(([key, values]) => (
              <S.RowBox key={key}>
                <S.CaNameBox>{key}</S.CaNameBox>
                <S.Row>
                  {values.map((item, index) => (
                    <S.ValueBox key={index}>
                      <S.ValueTitleBox>
                        <S.CbNameBox>{item.CB_NAME}</S.CbNameBox>
                        <S.CbCodeBox>{item.CB_CODE}</S.CbCodeBox>
                      </S.ValueTitleBox>
                      <S.Value>{item.value}</S.Value>
                    </S.ValueBox>
                  ))}
                </S.Row>
              </S.RowBox>
            ))
          : 'no data'}

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

0

For that you'll need to know the maximum length of any row. then rather than running a map over values values.map you can map over an array of that length. Like Array(maxLength).map then get the item :

<S.Row>
  {Array(maxLength).map((_, index) => {
    const item = values[index]
    return (
    <S.ValueBox key={index}>
     <S.ValueTitleBox>
       <S.CbNameBox>{item.CB_NAME}</S.CbNameBox>
       <S.CbCodeBox>{item.CB_CODE}</S.CbCodeBox>
     </S.ValueTitleBox>
     <S.Value>{item.value}</S.Value>
    </S.ValueBox>
   )})}
</S.Row>
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!