Skip to content

Commit

Permalink
Fixed navbar section warning
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnilnarad2000 committed Feb 5, 2024
1 parent 319e797 commit 943df45
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Components/NavbarSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Container from 'react-bootstrap/Container';
import Nav from 'react-bootstrap/Nav';
import Navbar from 'react-bootstrap/Navbar';
import React, { useState, useEffect } from 'react';
import { useCallback } from 'react';

import Image from 'react-bootstrap/Image';

Expand All @@ -16,7 +17,7 @@ let NavbarSection = () => {
const [overlay, setOverlay] = useState(false);
const [lastScrollY, setLastScrollY] = useState(0);

const controlNavbar = () => {
const controlNavbar = useCallback(() => {
if(window.scrollY === 0){
setOverlay(false);
}
Expand All @@ -29,7 +30,7 @@ let NavbarSection = () => {

// remember current page location to use in the next move
setLastScrollY(window.scrollY);
};
}, [lastScrollY]);

useEffect(() => {
window.addEventListener('scroll', controlNavbar);
Expand All @@ -38,7 +39,7 @@ let NavbarSection = () => {
return () => {
window.removeEventListener('scroll', controlNavbar);
};
}, [lastScrollY]);
}, [lastScrollY, controlNavbar]);


return (
Expand Down

0 comments on commit 943df45

Please sign in to comment.