# react-use-clock-hook

> react-use-clock-hook

Latest version **1.0.6** (published 2019-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-use-clock-hook
pnpm add react-use-clock-hook
yarn add react-use-clock-hook
bun add react-use-clock-hook
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2019-04-15 |
| First published | 2019-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alexander.khivrych |
| Maintainers | alexander.khivrych |
| Keywords | react, hooks, react-hooks, utils, lib, use-clock, clock, timer |

## Links

- npm: https://www.npmjs.com/package/react-use-clock-hook
- Repository: https://github.com/alexanderkhivrych/react-use-clock-hook
- Issues: https://github.com/alexanderkhivrych/react-use-clock-hook/issues
- npm.io page: https://npm.io/package/react-use-clock-hook

## Dependencies (3)

- [react](https://npm.io/package/react.md) ^16.8.6
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.8.6

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2019-04-15
- 1.0.5 — 2019-04-12
- 1.0.4 — 2019-04-12
- 1.0.3 — 2019-04-12
- 1.0.2 — 2019-04-12
- 1.0.1 — 2019-04-12
- 1.0.0 — 2019-04-12

## README

<div align="center">
  <h1>
    <br/>
    react-use-clock-hook ⏰
    <br />
  </h1>
    <sup>
    <br />
    <br />
    <a href="https://www.npmjs.com/package/react-use-clock-hook">
      <img src="https://img.shields.io/npm/v/react-use-clock-hook.svg" alt="npm package" />
    </a>
    <a href="https://www.npmjs.com/package/react-use-clock-hook">
      <img src="https://img.shields.io/npm/dm/react-use-clock-hook.svg" alt="npm downloads" />
    </a>
  </sup>
</div>

> 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 (
    <div>
      <div><b>Computer time:</b> {time}</div>
      <div><b>Raw time:</b> {raw.format("dddd, MMMM Do YYYY, h:mm:ss a")}</div>
    </div>
  );
}

export default App;
```

#### `useClock(<format: String>, <period: Number>)`
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)

---
_Source: https://npm.io/package/react-use-clock-hook · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
