use-current-date
v0.1.2
Published
A react hook that always returns the current date and rerenders the component when the date changes
Downloads
1
Readme
useCurrentDate
A simple utility hook for React that stores and provides the current date as state. When the date changes, the component renders.
Installation
You can install the package using either npm or yarn.
npm
npm install use-current-date
yarn
yarn add use-current-date
Usage
Here's an example of how you can use the useCurrentDate
hook in your React component:
import React from 'react';
import useCurrentDate from 'use-current-date';
const MyComponent = () => {
const currentDate = useCurrentDate();
return (
<div>
<h1>Current Date</h1>
<p>{currentDate.toDateString()}</p>
</div>
);
};
export default MyComponent;
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request on the GitHub repository.
Please make sure to follow the Contributor's Guide when submitting pull requests.
License
This project is licensed under the MIT License.
Feel free to modify the content to suit your specific package or add any additional sections you deem necessary.