1.1.0 • Published 6 years ago

react-live-time v1.1.0

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
6 years ago

React Live-Time

A simple time-ago component for React. Made with ❤️ using hooks!

NPM Codacy Badge JavaScript Style Guide Say Thanks! Donations Badge GitHub stars

Table of Contents

Installation

Using NPM:

npm i react-live-time

Using Yarn:

yarn add react-live-time

Usage

import React from 'react';
import ReactLiveTime from 'react-live-time';

function MyApp() {
  return <ReactLiveTime time={Date.now()} />;
}

Props

NameTypeDefaultDescription
timeDate/NumberundefinedThe value to be converted into timeago.
formatStringisoDateTimeThe format of the displayed date. This is only valid for dates 24-hours and over.
showSecondsBooleanfalseControls whether to show x seconds ago.. and maintain a timer for it.
classNameStringundefinedSpecify a custom class to the inner element.
idStringundefinedSpecify a custom ID to the inner element.
styleObjectundefinedSpecify custom inline styles to the inner element.
rendererFunctionundefinedA custom renderer, which gets all the following data as render props: {time, status, text, format }

Date Formats

The format props supports a large number of date formats. It relies on dateformat package. You can find the list of mask options and the predefined named formats.

Examples

There is a basic example up and running on the GitHub pages.

License

GPL-3.0 © samrith-s

1.1.0

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago