Skip to content
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

Minor update in the dependencies of the code: src/components/Navbar.jsx #17

Open
vignesh1507 opened this issue Oct 13, 2024 · 0 comments

Comments

@vignesh1507
Copy link

Dependencies in useEffect: You are using scrollPosition as a dependency in the useEffect. This can lead to an infinite loop because every time scrollPosition changes, it will trigger a re-evaluation of the effect. It’s better to use a ref for the scroll position:

const scrollPositionRef = useRef(scrollPosition);

Then update it inside the handleScroll function:

scrollPositionRef.current = currentScrollPos;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant