An open API service indexing awesome lists of open source software.

https://github.com/ceyhun/react-high-timer

A higher-order React timer component
https://github.com/ceyhun/react-high-timer

higher-order-component react react-native timer

Last synced: 2 months ago
JSON representation

A higher-order React timer component

Awesome Lists containing this project

README

          

# react-high-timer
A higher-order React timer component

You can replace your calls to `setTimeout(fn, 500)` with `this.props.setTimeout(fn, 500)` and everything will be properly cleaned up for you when the component unmounts.

## Installation

```sh
npm i react-high-timer
```

## Usage

```js
import * as React from 'react';
import { TimerProps, withTimer } from 'react-high-timer';

export class MyComponent extends React.Component {
componentDidMount() {
this.props.setInterval(() => {
console.log('I do not leak!');
}, 1000);
}
}

export default withTimer(MyComponent);
```