# react-timer-mixin

> TimerMixin provides timer functions for executing code in the future that are safely cleaned up when the component unmounts

Latest version **0.13.4** (published 2018-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-timer-mixin
pnpm add react-timer-mixin
yarn add react-timer-mixin
bun add react-timer-mixin
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.13.4 |
| Published | 2018-07-17 |
| First published | 2015-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 308 |
| Maintainers | aweary, sophiebits, tadeuzagallo |
| Keywords | react, timer, mixin |

## Links

- npm: https://www.npmjs.com/package/react-timer-mixin
- Repository: https://github.com/reactjs/react-timer-mixin
- Homepage: https://github.com/reactjs/react-timer-mixin#readme
- Issues: https://github.com/reactjs/react-timer-mixin/issues
- npm.io page: https://npm.io/package/react-timer-mixin

## 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.13.4 (latest) — 2018-07-17
- 0.13.3 — 2015-09-09
- 0.13.2 — 2015-07-03
- 0.13.1 — 2015-03-23
- 0.13.0 — 2015-03-20

## README

# react-timer-mixin

Using bare setTimeout, setInterval, setImmediate and requestAnimationFrame calls
is very dangerous because if you forget to cancel the request before the
component is unmounted, you risk the callback throwing an exception.

If you include TimerMixin, then you can replace your calls to
`setTimeout(fn, 500)` with `this.setTimeout(fn, 500)` (just prepend `this.`) and
everything will be properly cleaned up for you.

## Installation

Install the module directly from npm:

```
npm install react-timer-mixin
```

## Example

```js
var React = require('react');
var TimerMixin = require('react-timer-mixin');

var Component = React.createClass({
  mixins: [TimerMixin],
  componentDidMount() {
    this.setTimeout(
      () => { console.log('I do not leak!'); },
      500
    );
  }
});
```

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