Last active
August 12, 2020 21:26
-
-
Save donatoaguirre24/86f290f2c799e07b0104a88899e8597e to your computer and use it in GitHub Desktop.
Logs the renders count of a React component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef } from 'react'; | |
function useRendersCount(componentName) { | |
const renders = useRef(1); | |
console.log(`${componentName} renders count: ${renders.current++}`); | |
} | |
export default useRendersCount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment