Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda