feat(ui): add DevProfiler component for tracking render counts in dev mode #26165
+179
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a new
DevProfilercomponent that helps developers track component render counts during development. The component:process.env.NODE_ENV === "development") - returns children directly in productionuseRenderCount(componentName)hook for components to register themselves for tracking@coss/uicomponents (Badge, Button, Popover, ScrollArea) for consistent stylingUsage
Changes included
DevProfilercomponent inpackages/ui/components/dev-profiler/@coss/uias a dependency to@calcom/uipackages/ui/tsconfig.jsonfor@coss/ui/*importsUpdates since last revision
@coss/uicomponents (Badge, Button, Popover, ScrollArea) instead of custom classNames stylingVisual Demo (For contributors especially)
Badge (bottom-right corner):
Panel open with component statistics:
Color-coded render counts (red for >10 renders):
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
yarn dev)<DevProfiler>and useuseRenderCount("ComponentName")in components you want to trackChecklist
Human Review Checklist
process.env.NODE_ENV !== "development") properly tree-shakes in production buildsuseEffectwithout dependencies is intentional for tracking every renderforceUpdatepattern withuseReduceris appropriate for this use case@coss/uicomponents render correctly with the path mapping in tsconfig.json@coss/uidependency addition to@calcom/uiis appropriateLink to Devin run: https://app.devin.ai/sessions/5924bb3dc1a240d0a6ab93a68a4c429e
Requested by: @sean-brydon (sean@cal.com)