useTimeAgo
useTimeAgo(
timestamp):string
Defined in: useTimeAgo.ts:29
Live “time ago” display. Re-renders only when the formatted string crosses a boundary (e.g., “just now” → “1m ago”, “5m ago” → “6m ago”), not every clock tick.
Implementation note: the selector is the FORMATTED STRING, not the
raw timestamp. useSyncExternalStore skips re-renders when the
snapshot is Object.is-equal — so 30 rows showing “5m ago” each
subscribe to the same 1Hz clock, but only the row(s) crossing into
“6m ago” actually re-render.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
timestamp | number |
Returns
Section titled “Returns”string