# react-hooks-time-limit

> React Hook for get seconds to the target time

Latest version **1.0.6** (published 2022-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-hooks-time-limit
pnpm add react-hooks-time-limit
yarn add react-hooks-time-limit
bun add react-hooks-time-limit
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2022-01-13 |
| First published | 2021-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Shu Nakashima |
| Maintainers | shu20031026 |
| Keywords | react, typescript, hooks, target-time, hooks-api-react |

## Links

- npm: https://www.npmjs.com/package/react-hooks-time-limit
- Repository: https://github.com/shu20031026/react-hooks-time-limit
- Homepage: https://github.com/shu20031026/react-hooks-time-limit#readme
- Issues: https://github.com/shu20031026/react-hooks-time-limit/issues
- npm.io page: https://npm.io/package/react-hooks-time-limit

## 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) — 2022-01-13
- 1.0.5 — 2022-01-13
- 1.0.4 — 2021-12-28
- 1.0.3 — 2021-12-28
- 1.0.2 — 2021-12-28
- 1.0.1 — 2021-12-28
- 1.0.0 — 2021-12-28

## README

<h1 align="center">
  react-hooks-time-limit 
</h1>

[![npm](https://img.shields.io/npm/v/react-hooks-time-limit.svg?style=flat-square)](https://www.npmjs.com/package/react-hooks-time-limit)

<p align="center">
React Hook for get seconds to the target time
</p>

![](https://user-images.githubusercontent.com/75605907/149351384-eeabdbb4-4787-4c63-8672-d42cde6e1e5f.gif)


## Instrallation
You can install the package from npm.

```
$ npm install react-hooks-time-limit
```

or

```
$ yarn add react-hooks-time-limit
```


## Usage
This is the simplest example.

```tsx
import React from "react";
import { useTimeLimit } from "react-hooks-time-limit";

const getTomorrow = (): Date => {
  const date = new Date(Date.now());
  date.setDate(date.getDate() + 1);
  return date;
}

const Component: React.FC = () => {
  const tomorrow = getTomorrow();
  const [ timeLeft, setTargetTime ] = useTimeLimit(tomorrow, { isSec: true });

  const handleChangeDate = (event: React.ChangeEvent<HTMLInputElement>) => {
    const date = new Date(event.target.value)
    setTargetTime(date)
  }

  return (
    <div>
      <h2>{timeLeft} seconds left until the target time</h2>
      <p>change target time</p>
      <input type="date" onChange={handleChangeDate}/>
    </div>
  );
};
```

| Parameter          | Default |    Type   | Description                                           |
| :----------------- | :-----: | :-------: | ----------------------------------------------------- |
| intervalTime       |  `1000` |   `int`   | Time interval to update the remaining time (optional) |
| isSec              | `false` | `boolean` | Returns seconds if true, ms if false (optional)       |
## License
[MIT © shu20031026](./LICENSE)

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