diff --git a/README.md b/README.md index 57124ee..2b945f6 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,11 @@ > timeago-react is a simple react component used to format date with `*** time ago` statement. eg: '3 hours ago'. -**The component based on [timeago.js](https://github.com/hustcc/timeago.js)** which is a simple javascript module. +**Now uses native-time-ago** - a zero-dependency library using the native Intl.RelativeTimeFormat API. - - Realtime render. Automatic release the resources. - - Simple. Only 2kb. - - Efficient. When the time is `3 hour ago`, the interval will an hour (3600 * 1000 ms). - - Locales supported. + - Zero dependencies (uses native Intl.RelativeTimeFormat API) + - Supports 100+ languages automatically via native browser API + - No locale files needed [![npm](https://img.shields.io/npm/v/timeago-react.svg)](https://www.npmjs.com/package/timeago-react) [![build](https://github.com/hustcc/timeago-react/workflows/ci/badge.svg)](https://github.com/hustcc/timeago-react) diff --git a/packages/timeago-react/package.json b/packages/timeago-react/package.json index 96f9e2a..131e81d 100644 --- a/packages/timeago-react/package.json +++ b/packages/timeago-react/package.json @@ -59,8 +59,8 @@ "typescript-eslint": "^8.26.0", "vitest": "^3.0.7" }, - "dependencies": { - "timeago.js": "^4.0.0" +"dependencies": { + "native-time-ago": "1.0.1" }, "peerDependencies": { "react": "^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" diff --git a/packages/timeago-react/src/timeago-react.tsx b/packages/timeago-react/src/timeago-react.tsx index 146c14c..bc4745e 100644 --- a/packages/timeago-react/src/timeago-react.tsx +++ b/packages/timeago-react/src/timeago-react.tsx @@ -1,71 +1,27 @@ import * as React from 'react'; -import { format, cancel, render } from 'timeago.js'; -import { Opts, TDate } from 'timeago.js/lib/interface'; -export { Opts, TDate }; - -/** - * Convert input to a valid datetime string of