fix: ref usage in useIntersectionObserver and update Navbar

This commit is contained in:
Alvalens 2025-03-18 12:08:42 +07:00
parent bec725da38
commit 21d5b440d4
2 changed files with 14 additions and 16 deletions

View file

@ -17,13 +17,15 @@ export function useIntersectionObserver() {
}
);
if (ref.current) {
observer.observe(ref.current);
const currentRef = ref.current; // Store the ref value in a variable
if (currentRef) {
observer.observe(currentRef);
}
return () => {
if (ref.current) {
observer.unobserve(ref.current);
if (currentRef) {
observer.unobserve(currentRef);
}
};
}, []);