react component and hooks for timeago.js, for more information, please see: Document
npm i react-timeago.js
-
TimeAgo
Display
timeago
information insideelementType
tag base ondateTime
props- Props
props type required default description elementType string false div html tag name for the wrap component className string false undefined Custom class name dateTime Date / number / string true undefined start date options object false undefined options
- Options
options type default description locale string en_US locale localeRegister function custom local register function interval number 1000 update interval duration in milliseconds
-
return
timeago
string base ondateTime
props- Arguments
props type required default description dateTime Date / number / string true undefined start date options object false undefined options
- Options
options type default description locale string en_US locale localeRegister function custom local register function interval number 1000 update interval duration in milliseconds
- Common jS
// import from package entry point
const timeago = require('react-timeago.js')
<timeago.TimeAgo {...props} />
// only import specific component
const TimeAgo = require('react-timeago.js/lib/components/TimeAgo')
<TimeAgo {...props} />
- ESM
// import from package entry point
import TimeAgo, { useTimeAgo } from 'react-timeago.js'
const timeAgo = useTimeAgo(dateTime, options)
<TimeAgo {...props} />
// only import specific component
import TimeAgo from 'react-timeago.js/es/components/TimeAgo'
<TimeAgo {...props} />
npm install
npm start storybook
- configuration files list in
.storybook
directory - story files list in
.stories
directory
npm run test
__tests__
- unit test running by
jest
- use
test:update
to update jestsnapshot
- unit test running by