react-use/docs/useRendersCount.md
Anton Zinovyev 30abe2b22e
feat: add useFirstMountState & useRendersCount hooks (#769)
feat(useFirstMountState): hook to track if render is first;
feat(useRendersCount): hook to track renders count;
refactor(useUpdateEffect): now uses useFirstMountState hook;
refactor(usePreviousDistinct): now uses with useFirstMountState hook;
docs: update readme;
2019-11-23 15:14:35 +03:00

30 lines
523 B
Markdown

# `useRendersCount`
Tracks compontent'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();
```