Back

here is a little `TimeAgo` react component, that updates time, in real time:

import dayjs from 'dayjs';
import { useEffect, useState } from 'react';

export function TimeAgo({ date }) {
const [time, setTime] = useState(dayjs());

useEffect(() => {
const interval = setInterval(() => {
setTime(dayjs());
}, 1000);

return () => clearInterval(interval);
});

return <span>{dayjs(date).from(time)}</span>;
}

225

  • No matching results...
  • Searching...

/ 1000