Skip to content

Latest commit

 

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();