perf(react): hoist static render values - #6841
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryLow Risk Overview Docs search API — Comparisons landing page — Logs line chart — Workflow tag dropdown — No user-visible or API behavior changes; this targets React Doctor static-value warnings and minor render-time allocation. Reviewed by Cursor Bugbot for commit fc23bed. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR hoists static render and request values to module scope to avoid recreating them during execution.
Confidence Score: 4/5The PR appears safe to merge, with only a non-blocking TypeScript convention issue affecting the newly hoisted object constants. The hoisted values preserve existing runtime behavior and are not mutated, but three new object constants lack the repository-required const assertions. Files Needing Attention: apps/sim/app/(landing)/comparisons/page.tsx, apps/docs/app/api/search/route.ts, and tag-dropdown.tsx
|
| Filename | Overview |
|---|---|
| apps/docs/app/api/search/route.ts | Hoists the locale-to-PostgreSQL-search-configuration map without changing lookup behavior, but omits the required const assertion. |
| apps/sim/app/(landing)/comparisons/page.tsx | Hoists static breadcrumb JSON-LD while preserving rendered data, but the constant lacks the repository-required const assertion. |
| apps/sim/app/workspace/[workspaceId]/logs/components/dashboard/components/line-chart/line-chart.tsx | Hoists immutable chart padding with an appropriate const assertion; all consumers remain read-only. |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx | Safely shares an empty read-only-in-practice metadata map, though its declaration omits the required const assertion. |
Reviews (1): Last reviewed commit: "perf(react): hoist static render values" | Re-trigger Greptile
| const BREADCRUMB_JSON_LD = { | ||
| '@context': 'https://schema.org', | ||
| '@type': 'BreadcrumbList', | ||
| itemListElement: [ | ||
| { '@type': 'ListItem', position: 1, name: 'Home', item: baseUrl }, | ||
| { '@type': 'ListItem', position: 2, name: 'Comparisons', item: `${baseUrl}/comparisons` }, | ||
| ], | ||
| } |
There was a problem hiding this comment.
The newly hoisted BREADCRUMB_JSON_LD object lacks the repository-required as const assertion, leaving its inferred properties unnecessarily widened and mutable. The same changed-code pattern appears in LOCALE_MAP and EMPTY_VARIABLE_INFO_MAP.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
0ace85a to
67fd9ab
Compare
4f74386 to
fc23bed
Compare
Summary
Four values that do not depend on a render or request are now created once at module load. This removes repeated allocation and gives consumers a stable reference without changing their values.
The two remaining React Doctor warnings are intentional:
scrollingBoxesandfrozenBoxesare filled during each render, so hoisting them would leak stale collaborator selections.Type of Change
Testing
npx react-doctor@latest --verbose: only the 2 mutable-array false positives remainbun run check:api-validationpassedstagingChecklist
Screenshots/Videos
Not applicable. The hoisted values and their runtime contents are unchanged.
Post-Deploy Monitoring & Validation
No additional operational monitoring is required. These constants preserve their previous values and do not change user-visible behavior.