Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
How to Render this Array in array object

Hi I want to render this Advice on the screen but I could not do it I tried to map but that didn't helped please help me

import React, { useState, useEffect } from 'react'

export default function UsersData() {
  const [Users, setUsers] = useState([{
    "slip": {
      "id": 41,
      "advice": "Don't use Excel or Powerpoint documents for your basic word processing needs."
    }
  }])

  return(
    <>
      <h2> React Fetch API Example </h2>
        <ul>
          {/* Not sure what to write here */}
        </ul>
    </>
  )
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

I tried {Users.map(e=>{e.slip}) but it didn't work.

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

It should be as simple as writing a mapping function:

export default function UsersData() {
  const [Users, setUsers] = useState([
    {
      slip: {
        id: 41,
        advice:
          "Don't use Excel or Powerpoint documents for your basic word processing needs.",
      },
    },
  ]);

  return (
    <>
      <h2>React Fetch API Example</h2>
      <ul>
        {Users.map((user) => (
          <li key={user.slip.id}>{user.slip.advice}</li>
        ))}
      </ul>
    </>
  );
}

Here's a sample for your ref.

about 4 years ago · Santiago Trujillo Denunciar

0

Using map function you can print whole array and sample code below here.

<ul>
    {Users.map((element) => (
      <li key={element.slip.id}>{element.slip.advice}</li>
    ))}
  </ul>
about 4 years ago · Santiago Trujillo Denunciar

0

Use this:

import React, { useState, useEffect } from 'react'

export default function UsersData() {
  const [Users, setUsers] = useState([
    {

      "slip": {
      "id": 41,
      "advice": "Don't use Excel or Powerpoint documents for your basic word processing needs."
      }
      }
  ])



  return (
    <>
      <h2>React Fetch API Example</h2>
      <ul>
        {Users.map(({slip})=>(
           <li key={slip.id}>{slip.advice}</li>
        ))}
      
      </ul>
    </>
  )
}
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda