Last active
May 6, 2021 17:41
-
-
Save leegeunhyeok/4985710cd7d93023daa842c4cf0d6dfa to your computer and use it in GitHub Desktop.
Awesome Logger for React.Profiler
This file contains 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
<Profiler id="MyComponent" onRender={console.profile}> | |
<Component /> | |
</Profiler> |
This file contains 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
console.profile = function ReactProfileLogger (id, phase, actualDuration, baseDuration, startTime, commitTime, interactions) { | |
const baseStyle = 'padding:1px;background-color:#20232a;'; | |
console.log( | |
`%c ID: %c ${id} %c`, | |
baseStyle + 'color:#ffffff;border-radius:3px 0 0 3px;', | |
baseStyle + 'color:#61dafb;', | |
baseStyle + 'border-radius:0 3px 3px 0;' | |
); | |
console.group(); | |
console.log('actualDuration ' + actualDuration); | |
console.log('baseDuration ' + baseDuration); | |
console.log('startTime ' + startTime); | |
console.log('commitTime ' + commitTime); | |
console.log(interactions); | |
console.groupEnd(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment