0.0.14 • Published 4 years ago

@andordavoti/react-native-timeago v0.0.14

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

@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

NameTypeRequiredDescription
dateToDateyesdate you want the component to count to (uses the current date as a start).
dateFromDateoptionalOverwrite the current Date as a starting point.
hideAgobooleanoptionalHides the "ago" text.
updateIntervalnumberoptionalHow often the current date should update (only when using the "dateFrom" prop). Default is 60000 milliseconds
stylebooloptionalStyle passed to the Text component.

Contributing

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

License

MIT

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago