Whencomponent
When(props: WhenProps): ReactElement
| Param | Type | |
|---|---|---|
props | WhenProps | Props for When, Ago, and Until — a target date plus an optional current reference date and full toggle. required |
.target | PossibleDate | Values that can be converted to dates. |
.current | PossibleDate | Reference date the relative time is measured against. Defaults to "now" |
.full | boolean |
| Return | |
|---|---|
ReactElement | Rendered <time> element showing the relative time. |
| Throws | |
|---|---|
RequiredError | If target (or current) cannot be coerced to a valid date. |
Relative time — shows a signed string like in 6d or 3w ago wrapped in a <time> element carrying the machine-readable date.
Examples
<When target="2030-01-01" />