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

214
Views
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 answers
Answer question

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