mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
30 lines
522 B
Markdown
30 lines
522 B
Markdown
# `useRendersCount`
|
|
|
|
Tracks component's renders count including the first render.
|
|
|
|
## Usage
|
|
|
|
```typescript jsx
|
|
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
|
|
|
|
```typescript
|
|
const rendersCount: number = useRendersCount();
|
|
```
|