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

155
Views
Show api data in JSX, React

trying to load the props data into the jsx, when I try to iterate it inside the return, getting an error of .map not defined.

const SavedListTable = (props) => {
    console.log(props);
    const {listData, setListData} = props;
   
    if(setListData.length > 0) {
        return(
            setListData.map((setListData, index) => {
                console.log(setListData)
                return(
                    <div>
                        <tr>
                        <td >{setListData.name}</td>
                        <td >Project</td>
                        <td>00 May 2022</td>
                        </tr>
                    </div>

                )

            })
                                    
        )

    }

this is the response from for console.log(props)

{notes: Array(8)}
notes: (8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
[[Prototype]]: Object
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Use optional Chaining when using map function, it can cause errors sometimes due to the api response and when it comes, use optional chaining method in ES6. It will help you. And try to avoid console.log() in return, but if you want to use it, use like this {console.log()}

about 4 years ago · Juan Pablo Isaza Report

0

not a good question you can use array.map() to return this table rows

as this `const SavedListTable = (props) => {

return(
    props.notes.map((row) => (
        <div>
            <tr>
                <td >{row.name}</td>
            </tr>
        </div>
    ))
)

}`

use this package it would be more easier

https://www.npmjs.com/package/react-data-table-component

this is an example,you just have to parse array to DataTable component

https://react-data-table-component.netlify.app/?path=/docs/getting-started-examples--page

about 4 years ago · Juan Pablo Isaza Report

0

First pass the listData array and setListData function to props of this component and then you need to change setListData to listData, setListData is not the array but the function to set the list

const SavedListTable = (props) => {
    console.log(props);
    const {listData, setListData} = props;
   
    if(listData.length > 0) {
        return(
            listData.map((data, index) => {
                console.log(data)
                return(
                    <div>
                        <tr>
                        <td >{data.name}</td>
                        <td >Project</td>
                        <td>00 May 2022</td>
                        </tr>
                    </div>

                )

            })
                                    
        )

    }
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!