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

192
Views
have to make divider like in history

backlog - I am trying to make a copy of youtube and working on history page I want it to be displayed like this : to add some divider between videos

I have tried to do something myself and got this code

videos.map((video,index)=>{
                if(index>=1){
                    console.log(videos[index-1].watched_time);
                    if(videos[index-1].watched_time.split('T')[0]===video.watched_time.split('T')[0])
                        return <Video video={video} key={video.index}/>;
                    else{
                        index-=1;
                        return <Divider data={video.watched_time.split('T')[0]}/>
                }}
                else{
                    return <Video video={video} key={video.index}/>;
                }
            })}

The Result:
the result

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I would recommend that you first group the data by date and then run the loop.

I leave you an example:

const videos = [
  {
    name: 'v1',
    date: '2022-05-09'
  },
  {
    name: 'v2',
    date: '2022-05-10'
  },
  {
    name: 'v3',
    date: '2022-05-10'
  }
];

const grouped = videos.reduce((acc, ele) => {
  acc[ele.date] = (acc[ele.date] ?? []).concat([ele]);
  return acc;
}, {});

Object.entries(grouped).map(([title, videos]) => {
  console.log(title);
  // Component header
  // <Header value={title} />
  videos.map(video => {
    console.log(video);
    // Component Video
    // <Video video={video} key={video.index}/>
  });
});

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!