@andordavoti/react-native-timeago
TypeScript icon, indicating that this package has built-in type declarations

0.0.14 • Public • Published

@andordavoti/react-native-timeago

A simple auto-updating React Native timeago Component using date-fns.

Inspired by: react-native-timeago (replaced momentjs with date-fns due to momentjs now being legacy, and switched from class-based to functional).

Supports iOS, Android and Web. Written in Typescript.

Installation

Run:

npm i @andordavoti/react-native-timeago

Import the module:

import TimeAgo from '@andordavoti/react-native-timeago';

Usage

Use it as a regular React Native Text component and pass it a Date. Other optional props can be passed which are specified bellow. There is also an Expo app example in the repo under the example folder.

import React from 'react';
import TimeAgo from '@andordavoti/react-native-timeago';

const App: React.FC = () => {
  return <TimeAgo dateTo={new Date(1536484369695)} />;
};

export default App;

Props

Name Type Required Description
dateTo Date yes date you want the component to count to (uses the current date as a start).
dateFrom Date optional Overwrite the current Date as a starting point.
hideAgo boolean optional Hides the "ago" text.
updateInterval number optional How often the current date should update (only when using the "dateFrom" prop). Default is 60000 milliseconds
style bool optional Style passed to the Text component.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Package Sidebar

Install

npm i @andordavoti/react-native-timeago

Weekly Downloads

31

Version

0.0.14

License

MIT

Unpacked Size

14.1 kB

Total Files

9

Last publish

Collaborators

  • andordavoti