use-rev
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

npm version Downloads Uses TypeScript

use-rev

A revision counter React hook.

This hook returns a number (a revision), and a function to increment the revision (the bump function).

  • The revision is guaranteed to always be truthy.
  • If the revision reaches Number.MAX_SAFE_INTEGER, it wraps back to 1.
  • The bump function is memoized with useCallback and will never change.

Usage

import { useRev } from 'use-rev';

// (inside a React component)
const [rev, bumpRev] = useRev();

Package Sidebar

Install

npm i use-rev

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

6.86 kB

Total Files

9

Last publish

Collaborators

  • ts-web