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

129
Views
React map method return currentElement.name where name inside another array

Hi i just want to render a table where name column name and its value dynmamically fetch from an api .. and I store column value in an new array ; I want to return rows value that link with column name in a row

const element = [ "ENDURANCE", "SPEED", "AGILITY", "STRENGTH" ] // this is my column name

api data of rows value

 
​
[
    {
        AGILITY: 1
        ENDURANCE: 1
        SPEED: 1
        STRENGTH: 1
        _id: "62c53266b631f27c54db8d89"
        date: "7/6/2022"
    }, {
        AGILITY: "4"
        ENDURANCE: "4"
        SPEED: "6"
        STRENGTH: "2"
        _id: "62c5a047a053c4ebb5de8c10"
        date: "7/6/2022"
    },
    ​{
        AGILITY: "8"
        ENDURANCE: "6"
        SPEED: "5"
        STRENGTH: "10"
        _id: "62c5a053a053c4ebb5de8c14"
        date: "7/6/2022"
    }
]

I just map this value in table dynamically this is my code ....

 <table className="table">
                    <thead>
                      <tr>
                        <th>/</th>
                        <th>Date</th>

                        {props.data.map((cur, i) => {
                          element.push(cur[0])  //store all column names
                          return <th key={i}>{cur[0]}</th>;
                        })}
                      </tr>
                    </thead>
                    <tbody>
                      {props.stdata.map((curr, index) => {
                        
                        console.log(element);
                        return (
                          <>
                            <tr>
                              <td>{index+1}</td>
                              <td>
                                {curr.date} // date element is same in every api data
                              </td>
                              <td>{
                                curr[element] // may be this is wrong
                                }</td>
                            </tr>
                          </>
                        );
                      
                      })}
                    </tbody>
                  </table>

this is how table looks enter image description here

about 4 years ago · Juan Pablo Isaza
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!