Viktor
Viktor

Reputation: 353

Is it possible to list time in 24h format in react?

So I'm kinda new with react and I wanna ask, is it possible to list time in 24h format as a grid?

Like:

12:00
13:00
14:00
15:00

and so on...There are no exceptions, it should show all.

Haven't found any component or internal feature for this.

Would be grateful if you could help me.

Upvotes: 0

Views: 345

Answers (1)

Nadia Chibrikova
Nadia Chibrikova

Reputation: 5036

You'll need to add a checkbox to each and remember selection in the state but the bare minimum will be something like

const MyClock = React.memo(() => {
 const clock=[]
 for(let i=0; i<24; i++)
   clock.push( <li key={i}>{(i+":00").padStart(5,"0")}</li>);
 return clock;
});

Upvotes: 1

Related Questions