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

123
Views
Cómo renderizar esta matriz en un objeto de matriz

Hola, quiero mostrar este consejo en la pantalla, pero no pude hacerlo. Traté de mapear pero eso no ayudó. Por favor, ayúdenme.

 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>

{Users.map(e=>{e.slip}) pero no funcionó.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Debería ser tan simple como escribir una función de mapeo:

 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> </> ); }

Aquí hay una muestra para su ref.

about 4 years ago · Santiago Trujillo Report

0

Usando la función de mapa, puede imprimir toda la matriz y el código de muestra a continuación aquí.

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

0

Utilizar este:

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