Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexanderkhivrych/react-use-clock-hook
react-use-clock-hook
https://github.com/alexanderkhivrych/react-use-clock-hook
clock hooks js moment react react-library webpack
Last synced: about 1 month ago
JSON representation
react-use-clock-hook
- Host: GitHub
- URL: https://github.com/alexanderkhivrych/react-use-clock-hook
- Owner: alexanderkhivrych
- Created: 2019-04-12T08:43:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-04-15T07:23:50.000Z (over 5 years ago)
- Last Synced: 2024-11-29T05:45:41.324Z (about 1 month ago)
- Topics: clock, hooks, js, moment, react, react-library, webpack
- Language: JavaScript
- Size: 224 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
> React Hook for sharing clock logic
## Install
```bash
#With npm
npm install react-use-clock-hook --save
``````bash
#With yarn
yarn add react-use-clock-hook
```## Usage
```jsx
import React from 'react';
import useClock from 'react-use-clock-hook';const App = () => {
const { time, raw } = useClock("HH:mm:ss");return (
Computer time: {time}
Raw time: {raw.format("dddd, MMMM Do YYYY, h:mm:ss a")}
);
}export default App;
```#### `useClock(, )`
Param | Type | Default | Description
--- | --- | --- | ---
format | `String` | `"DD/MM/YYYY HH:mm:ss"` | Any string accepted by [`moment.format`](https://momentjs.com/docs/#/displaying/format/)
period | `Number` | `1000` | Time, in miliseconds, that the clock is updated## Dependency
[moment](https://github.com/moment/moment)
## License
MIT © [alexanderkhivrych](https://github.com/alexanderkhivrych)