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
- Host: GitHub
- URL: https://github.com/ceyhun/react-high-timer
- Owner: ceyhun
- License: mit
- Created: 2017-08-26T11:19:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-31T09:04:15.000Z (almost 9 years ago)
- Last Synced: 2025-05-21T04:53:08.327Z (about 1 year ago)
- Topics: higher-order-component, react, react-native, timer
- Language: TypeScript
- Size: 17.6 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
```