react-high-timer
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

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

npm i react-high-timer

Usage

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

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

export default withTimer(MyComponent);

Package Sidebar

Install

npm i react-high-timer

Weekly Downloads

0

Version

4.0.0

License

MIT

Last publish

Collaborators

  • ceyhuno