-
-
Notifications
You must be signed in to change notification settings - Fork 1
Performance: Eliminate redundant animation loops and unnecessary re-renders #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Here's the code health analysis summary for commits Analysis Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ptimize re-renders Co-authored-by: Keyyard <84187238+Keyyard@users.noreply.github.com>
Co-authored-by: Keyyard <84187238+Keyyard@users.noreply.github.com>
Co-authored-by: Keyyard <84187238+Keyyard@users.noreply.github.com>
Co-authored-by: Keyyard <84187238+Keyyard@users.noreply.github.com>
Co-authored-by: Keyyard <84187238+Keyyard@users.noreply.github.com>
|
what is the use of useMemo and useCallback @copilot |
// Without useMemo: sorts on every render
const sorted = [...posts].sort((a, b) => b.date - a.date);
// With useMemo: only re-sorts when posts array changes
const sorted = useMemo(() => {
return [...posts].sort((a, b) => b.date - a.date);
}, [posts]);
// Without useCallback: new function created on every render
const handleClick = (exp) => setSelectedExperience(exp);
// With useCallback: same function reference maintained
const handleClick = useCallback((exp) => {
setSelectedExperience(exp);
}, []);Why this matters in your codebase:
This prevents child components wrapped in |
Identified and fixed performance bottlenecks causing excessive CPU usage and slow render times.
Critical Fixes
Redundant animation loop in 3D head component
requestAnimationFrameloop ANDuseFramehook simultaneouslyuseFramehandler, eliminated continuous background loopResize handler causing render storms
IntersectionObserver triggering unnecessary updates
React.memo Coverage
Added memoization to 11 components that render static or infrequently-changing content:
Event Handler Optimization
Wrapped handlers in
useCallbackto prevent recreation on every render:Computation Memoization
Applied
useMemoto expensive operations:Config
eslint-plugin-nextdependencyout/to ignore patternsreact/prop-types(using TypeScript)Impact
Build time: 12.5s → 7.6s (39% improvement)
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.