JSPM

react-timesago

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q26697F
  • License MIT

React-TimesAgo is a component that takes a date as a prop and returns a time-span with live updating date.

Package Exports

  • react-timesago

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-timesago) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React-TimesAgo

React-TimesAgo is a component that takes a date as a prop and returns a time-span with live updating date.

Demo

React-TimesAgo

Installation

  1. Install React-TimesAgo as a dependency
# NPM
npm install react-timesago
  1. Import the react-timesago module
// ES6
import TimesAgo from "react-timesago";

Example

import TimesAgo from 'react-timesago';

render() {
<TimesAgo time={date} type="default" suffix="ago" /> // type default
<TimesAgo time={date} type="default" prefix="before" /> // type default
<TimesAgo time={date} type="facebook" /> // type facebook
}

Props

These are all of the available props (and their default values) for the <TimesAgo /> component.

{
    prefix: "",
    suffix: "ago",
    type: "default",
    time: new Date(1551788578911 * 1000)
}

Props Details

  • prefix - formatter prefix for date, ignored for type facebook.
  • suffix - formatter suffix for date, ignored for type facebook.
  • type - types for date format (facebook or default)
  • time - date.