mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix ImageBanner unnecessary re-render
This commit is contained in:
@@ -4,6 +4,8 @@ import { useLocation } from 'react-router-dom';
|
|||||||
const ImageBanner = () => {
|
const ImageBanner = () => {
|
||||||
const [currentImage, setCurrentImage] = useState(null);
|
const [currentImage, setCurrentImage] = useState(null);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
|
const parentRoute = location.pathname.split('/').slice(0, 3).join('/');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let isMounted = true;
|
let isMounted = true;
|
||||||
@@ -27,7 +29,7 @@ const ImageBanner = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
isMounted = false;
|
isMounted = false;
|
||||||
};
|
};
|
||||||
}, [location.key]);
|
}, [parentRoute]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user