React Livestamp
Auto updating timeago text to your timestamped for React
Installation
npm install react-livestamp --save
Basic Usage
;; // Dummy dateconst end_date = ; // add 5 hours.end_date; Component { return <Livestamp end=end_date /> }
Props
end (required)
Accepts a Date object, a String format, or a Number timestamp
.
const end_time = ; // Object instanceof dateconst str_end = end_date // Tue Jun 14 2016 21:25:41 GMT+0300 (EEST)const timestamp_end = end_date // 1465928741178 <Livestamp end=end_time /><Livestamp end=str_end /><Livestamp end=timestamp_end />
interval (optional)
The second parameter for setInterval is optional with default value of 1000
.
renderStamp (optional)
Component { return <div className="react-livestamp"> <b>days g hours s minutes dk seconds sn</b> </div> } { return // Default renderStamp template <Livestamp end=end_time renderStamp= <div className="react-livestamp"> <b>days g hours s minutes dk seconds sn</b> </div> /> // or may be in this way: <Livestamp renderStamp=thisrenderStamp> }
renderExpired (optional)
If the livestamp ends it run this.
Component { return <div className="react-livestamp"> Date Expired </div> } { return // Default renderStamp template <Livestamp end=end_time renderExpired= <div className="react-livestamp"> Date Expired </div> /> // or may be in this way: <Livestamp renderExpired=thisrenderExpired> }
Development
npm installnpm start # watch and build.