Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 735 Bytes

useRenderCount.md

File metadata and controls

37 lines (25 loc) · 735 Bytes

useRenderCount

A hook to count the number of times a component has rendered.

Arguments

  • None

Returns

  • The number of times the component has rendered.

Hooks Involved

How to Use

import useRenderCount from "./useRenderCount"
import useToggle from "../useToggle/useToggle"

export default function RenderCountComponent() {
    const [boolean, toggle] = useToggle(false)

    const renderCount = useRenderCount()

    return (
        <>
            <div>{boolean.toString()}</div>
            <div>{renderCount}</div>
            <button onClick={toggle}>Toggle</button>
        </>
    )
}