Skip to content

Files

Latest commit

e4eec7b Β· Mar 5, 2020

History

History
29 lines (22 loc) Β· 522 Bytes

useRendersCount.md

File metadata and controls

29 lines (22 loc) Β· 522 Bytes

useRendersCount

Tracks component's renders count including the first render.

Usage

import * as React from 'react';
import { useRendersCount } from "react-use";  

const Demo = () => {
  const update = useUpdate();
  const rendersCount = useRendersCount();

  return (
    <div>
      <span>Renders count: {rendersCount}</span>
      <br />
      <button onClick={update}>re-render</button>
    </div>
  );
};

Reference

const rendersCount: number = useRendersCount();