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

210
Vistas
How to add different text after the map function has rendered 3 times?

I want to add some text after the cards have rendered three times. these cards take value from a local json file using split and map. i also want to change the text every three times the component has rendered.

import React from 'react';
import data from '../data.json';
import { Card,Button } from 'react-bootstrap';

function Med() {
    
    return (
        <div>
                {data.slice(0,6).map((item)=>{
                    return (
                        <div>
                            <Card style={{ width: '18rem' }}>
                                <Card.Body>
                                    <Card.Title>{item.Name}</Card.Title>
                                    <Card.Text>
                                        This is the explaination of product card.
                                    </Card.Text>
                                    <Button variant="primary">Add to cart</Button>
                                </Card.Body>
                            </Card>                           
                        </div>   
                    )
                    
                })}       
        </div>
    )
}

export default Med;

This is my current output. but I want it to display some text after chris's card.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

{data.slice(0,6).map((item,index)=>{//use the index to conditionally render })}

Edit #1 - So, after reading your comment maybe this code will give you an idea

{data.slice(0, 6).map((item, index) => {
return (
 <div>
   {index < 3 ? <h1>First three</h1> : <h1>From Fourth</h1>
 </div>
);
})} 
about 4 years ago · Juan Pablo Isaza 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