Open
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| mousePos: React.RefObject<{ x: number; y: number }> | ||
| strength: number | ||
| ease: number | ||
| isHovered: React.RefObject<boolean> |
Contributor
There was a problem hiding this comment.
isHovered ref is set but never read - can be removed from context and component
Prompt To Fix With AI
This is a comment left during a code review.
Path: registry/joyco/blocks/magnetic.tsx
Line: 17:17
Comment:
`isHovered` ref is set but never read - can be removed from context and component
How can I resolve this? If you propose a fix, please make it concise.- Changed the implementation of Root and Inner components to use function syntax instead of forwardRef for better clarity. - Introduced applyTick and applyLeave functions to encapsulate animation logic and reduce redundancy. - Removed unnecessary comments and streamlined the useEffect hooks for improved performance and maintainability.
- Added an eslint-disable comment to the useEffect hook to indicate that applyTick/applyLeave are effect events and rootRef is a stable reference, improving code clarity and maintaining eslint compliance.
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.
Greptile Overview
Greptile Summary
This PR adds a well-crafted Magnetic component that creates a cursor-attraction effect. The implementation follows best practices with React Context for state management,
useEffectEventfor stable callbacks, and proper accessibility support viaprefers-reduced-motion. The component uses RAF-based animation with smooth interpolation and provides a clean API withasChildsupport via Radix Slot.Key highlights:
prefers-reduced-motionfor accessibilitytransform(compositor-friendly)Previous review comments already identified the remaining issues:
getBoundingClientRect()called in RAF loop (should cache on mouseenter)isHoveredref set but never readConfidence Score: 4/5
getBoundingClientRectin RAF loop, coordinate mixing, unused ref). These are optimization opportunities rather than critical bugs - the component functions correctly but could be more performant.Important Files Changed
Last reviewed commit: c89b688
Context used:
dashboard- Registry Guidelines (source)dashboard- AGENTS.md (source)