# react-countdown-hoc

> countdown React component

Latest version **0.1.6** (published 2020-05-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-countdown-hoc
pnpm add react-countdown-hoc
yarn add react-countdown-hoc
bun add react-countdown-hoc
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2020-05-08 |
| First published | 2020-04-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 42.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | wenisy |
| Maintainers | wenisy |
| Keywords | react-component, react, countdown, react-component-countdown |

## Links

- npm: https://www.npmjs.com/package/react-countdown-hoc
- Repository: https://github.com/wenisy/react-countdown
- npm.io page: https://npm.io/package/react-countdown-hoc

## 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

- 0.1.6 (latest) — 2020-05-08
- 0.1.5 — 2020-04-24
- 0.1.3 — 2020-04-24
- 0.1.2 — 2020-04-24
- 0.1.1 — 2020-04-24
- 0.1.0 — 2020-04-24
- 0.0.3 — 2020-04-24
- 0.0.2 — 2020-04-24
- 0.0.1 — 2020-04-24

## README

# React Countdown HOC
It's a `render props` component, or `FaCC(Function as Child Component)`.

know more details about `render props` [Render Props – React](https://reactjs.org/docs/render-props.html)

## Use this Component
`yarn add react-countdown-hoc` to install the latest version

```javascript
<Countdown intervalSecond={1} duration={60}>
  {(isCounting, restTime, startCount) => (
    <button disabled={isCounting} onClick={() => startCounting(startCount)}>
      {isCounting ? `${restTime}s` : 'done'}
    </button>
  )}
</Countdown>
```

## Props
|Name|Type|Default|Description|
|:--|:--:|:-----:|:----------|
|intervalSecond|`number`|`required`|Interval delay in second|
|duration|`number`|`required`|Count down time|
|[**children**](#children)|`number`|`(isCounting: boolean, durationTime: number, startCount: () => void) => React.ReactNode`|A React child for the countdown's state|
|autoTrigger|`boolean`|`undefined`|When Component mounted, auto starting count|
|detectChanges|`string`|`undefined`|A compare condition to rerender countdown |

### `children`
You could put a button here but start counting, and display rest of time.

`isCounting` is a flag to tell you if countdown completed

`durationTime` tells you rest time for current countdown

`startCount` is a function, to start count



## Contribute to this repo

To install dependencies

```
$ yarn
```

To build

```
$ yarn build
```

To run tests

```
$ yarn test
```

To run Storybook

```
$ yarn start
```

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