fix: react-doctor issues (conditional hooks, a11y, perf)#761
Open
joejohnson123[bot] wants to merge 1 commit intodevfrom
Open
fix: react-doctor issues (conditional hooks, a11y, perf)#761joejohnson123[bot] wants to merge 1 commit intodevfrom
joejohnson123[bot] wants to merge 1 commit intodevfrom
Conversation
…ality - Fix conditional useMemo calls in OrderSummary (ERROR: hooks called after early return) - Replace array index keys with stable keys in background-beams and attach-confirmation-info - Use lazy state initializer in QuantityInput - Change scale: 0 to scale: 0.95 in PlanSelectionCard animations - Extract default prop values to module-level constants (CopyablePre, TagSelect) - Use specific lodash/debounce import instead of full lodash - Add role and keyboard event handlers for a11y (CopyablePre, ProductListColumns, TagSelect)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| {infoBoxes.map((box, index) => ( | ||
| <div key={index}>{box}</div> | ||
| {infoBoxes.map((box) => ( | ||
| <div key={(box as React.ReactElement).key}>{box}</div> |
Contributor
There was a problem hiding this comment.
Type assertion may fail at runtime if box is not a ReactElement. The renderInfoBoxes() function returns ReactNode[] which can include strings, numbers, fragments, etc. All current boxes do have explicit keys, but this is fragile.
Prompt To Fix With AI
This is a comment left during a code review.
Path: vite/src/components/forms/attach-product/attach-confirmation-info.tsx
Line: 138
Comment:
Type assertion may fail at runtime if box is not a ReactElement. The renderInfoBoxes() function returns ReactNode[] which can include strings, numbers, fragments, etc. All current boxes do have explicit keys, but this is fragile.
How can I resolve this? If you propose a fix, please make it concise.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes from react-doctor scan.
Summary by cubic
Fixes react-doctor findings by correcting hook order in OrderSummary and improving accessibility. Also adds stable keys and small performance tweaks across components.
Bug Fixes
Performance
Written for commit 67da824. Summary will update on new commits.
Greptile Summary
Automated fixes from react-doctor scan addressing React best practices, accessibility, and performance issues.
Key Changes:
OrderSummary.tsxby moving alluseMemocalls before early return to comply with React's Rules of Hooksrole,tabIndex,onKeyDown) to interactive elements inCopyablePre.tsx,TagSelect.tsx, andProductListColumns.tsxbackground-beams.tsx,attach-confirmation-info.tsx) for proper component reconciliationCopyablePre.tsx,TagSelect.tsx)PlanSelectionCard.tsxto reduce layout shiftQuantityInput.tsxand switched to specific lodash imports inuseCusProductQuery.tsxto reduce bundle sizeConfidence Score: 4/5
Important Files Changed
useMemocalls before early returnlodash/debounceimport to reduce bundle sizeLast reviewed commit: 67da824
(2/5) Greptile learns from your feedback when you react with thumbs up/down!