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

112
Views
Repita dos a la vez con un mapa

Por ejemplo, id... Quiero -> "ID" en una línea 1, 2, siguiente línea 3, 4 siguiente línea 5, 6 ahora -> una línea 1, 1 siguiente línea 2, 2 siguiente línea 3, 3. ¿Qué tengo que hacer? Por ejemplo, id... Quiero -> "ID" en una línea 1, 2, siguiente línea 3, 4 siguiente línea 5, 6 ahora -> una línea 1, 1 siguiente línea 2, 2 siguiente línea 3, 3. ¿Qué tengo que hacer?

 //app.js const [data, setData] = useState([]); useEffect(() => { fetch('http://localhost:3001/data/mainData.json') .then(res => res.json()) .then(data => { setData(data); }); }, []); <ImgContainer> {data.map(imgList => { return ( <ImgBox> <ImgWrap to={`/${imgList.text}`} key={imgList.id}> <Img src={imgList.src} alt={imgList.text} /> <Text>{imgList.text}</Text> </ImgWrap> <ImgWrap to={`/${imgList.text}`} key={imgList.id}> <Img src={imgList.src} alt={imgList.text} /> <Text>{imgList.text}</Text> </ImgWrap> </ImgBox> ); })} </ImgContainer>
 //json [ { "id": 1, "src": "/images/bathMain.jpg", "text": "Bath" }, { "id": 2, "src": "/images/livingMain.jpg", "text": "Living" }, { "id": 3, "src": "/images/kitchenMain.jpg", "text": "Kitchen" }, { "id": 4, "src": "/images/diningMain.jpg", "text": "Dining" }, { "id": 5, "src": "/images/bedMain.jpg", "text": "Bed Room" }, { "id": 6, "src": "/images/dressMain.jpg", "text": "Dress Room" } ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Una forma de hacer esto sería crear su expresión fuera de la declaración de retorno, usando un bucle for simple:

 let val = [ { id: 1, src: "/images/bathMain.jpg", text: "Bath" }, { id: 2, src: "/images/livingMain.jpg", text: "Living" }, { id: 3, src: "/images/kitchenMain.jpg", text: "Kitchen" }, { id: 4, src: "/images/diningMain.jpg", text: "Dining" }, { id: 5, src: "/images/bedMain.jpg", text: "Bed Room" }, { id: 6, src: "/images/dressMain.jpg", text: "Dress Room" } ]; let expr = []; for (let i = 0; i < val.length; i=i+2) { expr.push( <> <p>{val[i].id}</p> <p>{val[i+1].id}</p> </> ); } return <div className="App">{expr}</div>;

Enlace

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!