mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 05:59:45 +00:00
Обнуление скролла при переходе между страницами
This commit is contained in:
1 parent
5d1c74b212
commit
3a1cac0dfe
2 files changed
+16
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
const ScrollToTop = () => {
|
||||
const { pathname } = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, [pathname]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default ScrollToTop;
|
||||
@@ -2,6 +2,7 @@ import { Outlet } from "react-router-dom";
|
||||
import { createContext, useEffect, useState } from 'react';
|
||||
|
||||
import useElementOnScreen from '../../lib/useElementOnScreen';
|
||||
import ScrollToTop from "../../lib/scrollToTop";
|
||||
import Navbar from '../../components/Navbar';
|
||||
import Footer from '../../components/Footer';
|
||||
import './Root.styles.scss';
|
||||
@@ -63,6 +64,7 @@ function Root() {
|
||||
|
||||
return (
|
||||
<RootContext.Provider value={{ setRef }}>
|
||||
<ScrollToTop />
|
||||
<Navbar />
|
||||
<div id="react-page">
|
||||
<Outlet />
|
||||
|
||||
Reference in new issue
Block a user