fix ImageBanner unnecessary re-render

This commit is contained in:
plebbitor
2023-04-20 14:07:46 +02:00
parent ee7a2f857b
commit aeed535c33
+3 -1
View File
@@ -4,6 +4,8 @@ import { useLocation } from 'react-router-dom';
const ImageBanner = () => {
const [currentImage, setCurrentImage] = useState(null);
const location = useLocation();
const parentRoute = location.pathname.split('/').slice(0, 3).join('/');
useEffect(() => {
let isMounted = true;
@@ -27,7 +29,7 @@ const ImageBanner = () => {
return () => {
isMounted = false;
};
}, [location.key]);
}, [parentRoute]);
return (
<>