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

163
Visualizações
Cómo mapear sobre 2 matrices de objetos en React y renderizar en Table

¿Cómo puedo mapear sobre 2 matrices de objetos en React y renderizar en una tabla? ¿Cuáles son las opciones para este problema? ¿Debo fusionar estos dos arreglos en uno? Verifique los datos de Json

 let URL1 = "http://api_url/users" let URL2 = "http://api_url/users-card" const promise1 = axios.post(URL1, inputValue , {headers: {'Content-Type': 'text/plain'}}); const promise2 = axios.post(URL2, inputValue , {headers: {'Content-Type': 'text/plain'}}); Promise.all([promise1, promise2]).then(function(values) { setDataSetOne(values[0]); setDataSetTwo(values[1]); });
 <TableContainer> <Table> <TableHead> <TableRow> <TableCell>Dessert (100g serving)</TableCell> <TableCell align="right">Calories</TableCell> <TableCell align="right">Fat&nbsp;(g)</TableCell> </TableRow> </TableHead> <TableBody> <TableCell>DataOne</TableCell> <TableCell>DataOne</TableCell> <TableCell>DataTwo</TableCell> </TableBody> </Table> </TableContainer>

Datos Json 1.º

 [{ "name": "adnan hassan", "count": 6960 }, { "name": "adnan", "count": 69666660 }]

2.º datos Json

 [{ "keyword_idea_metrics": { "competition": "LOW", "avg_monthly_searches": "6600", "competition_index": "22", "low_top_of_page_bid_micros": "53135896", "high_top_of_page_bid_micros": "278963954" }, "keyword_annotations": { "concepts": [] }, "text": "dubai homes", "_text": "text" }]

Editar: se han agregado datos Json

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Puede usar un objeto para contener dos estados como este:

 import { useEffect, useState } from 'react'; import axios from 'axios'; const App = () => { // use one object to contain two states const [data, setData] = useState({ dataOne: '', dataTow: '' }); // fetch data useEffect(() => { const fetchData = async () => { const dataOne = await axios.post(URL1, inputValue, { headers: { 'Content-Type': 'text/plain' }, }); const dataTow = await axios.post(URL2, inputValue, { headers: { 'Content-Type': 'text/plain' }, }); setData({ dataOne, dataTow }); }; fetchData(); }, []); // display data return ( <TableContainer> <Table> <TableHead> <TableRow> <TableCell>Dessert (100g serving)</TableCell> <TableCell align="right">Calories</TableCell> <TableCell align="right">Fat&nbsp;(g)</TableCell> </TableRow> </TableHead> <TableBody> <TableCell>{data.dataOne}</TableCell> <TableCell>{data.dataTow}</TableCell> </TableBody> </Table> </TableContainer> ); }; export default App;

Espero que sea útil.

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