use-react-countdown
v1.0.4
Published
A simple hook, that will return days, hours, minutes and seconds (changing), accepting a date as an input
Downloads
400
Maintainers
Readme
Installation
Using npm:
$ npm install use-react-countdown
Using yarn:
$ yarn add use-react-countdown
Quick Start
import React from "react";
import useReactCountdown from "use-react-countdown";
const render = () => {
let dateToEndCountdownAt = "July 22, 2021 00:00:00";
const { days, hours, minutes, seconds } =
useReactCountdown(dateToEndCountdownAt);
return (
<>
<p>Time left</p>
<div>
{days} {hours} {minutes} {seconds}
</div>
</>
);
};
Note that this is a very basic usage. Check out more usage examples in playground
Documentation
{days, hours, minutes, seconds} = useReactCountdown(dateToEndCountdownAt)
Parameters
Takes a default countdown time and interval time.
dateToEndCountdownAt
{string
} Date in format (Month DD, YYYY hh:mm:ss)
Return value
Returns an object with days, hours, minutes and seconds left in that date.
days
{Number
} Remaining dayshours
{Number
} Remaining hoursminutes
{Number
} Remaining minutesseconds
{Number
} Remaining seconds
Contributing
Feel free to submit any issues or pull requests.