Navbar Component Re-renders Multiple Times on Dynamic Route Changes #67262
Replies: 1 comment
-
Hey man, I wonder did you find out any solutions for this problem yet, I have been doing my personal project for this and facing with this problem, it's kind of frustrating.... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Description:
I'm encountering an issue with my Navbar component in Next.js where it re-renders multiple times specifically during dynamic route changes. This behavior occurs even after optimizing with React.memo and ensuring that only necessary props are used. I've logged when the Navbar component re-renders and noticed it happens more times than expected.
Key Details:
I'm using Next.js 14.2.3 [App Router] with React 18.3.1.
The Navbar component is memoized using React.memo for optimization.
I've verified dependencies in useEffect and ensured they're properly managed.
The issue specifically arises during dynamic route changes (/post/[postId], /portfolio/[portfolioId], etc.).
Despite efforts to minimize state updates and efficiently use props, the Navbar continues to re-render excessively.
I'm seeking advice on further optimizing the Navbar to reduce unnecessary re-renders during dynamic route transitions.
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions