mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
22 lines
453 B
TypeScript
22 lines
453 B
TypeScript
|
import { useEffect } from 'react';
|
||
|
import { useLocation } from 'react-router-dom';
|
||
|
|
||
|
export const ScrollTop = (): null => {
|
||
|
const { pathname } = useLocation();
|
||
|
|
||
|
useEffect(() => {
|
||
|
if (!noScrollPaths.some(noScroll => pathname.includes(noScroll))) {
|
||
|
window.scrollTo(0, 0);
|
||
|
}
|
||
|
}, [pathname]);
|
||
|
|
||
|
return null;
|
||
|
};
|
||
|
|
||
|
const noScrollPaths = [
|
||
|
'/admin/api',
|
||
|
'/admin/users',
|
||
|
'/admin/auth',
|
||
|
'/admin/roles',
|
||
|
];
|