mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-08-29 02:25:26 +00:00
Fix scroll restoration
This commit is contained in:
24
src/App.jsx
24
src/App.jsx
@@ -1,26 +1,34 @@
|
||||
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
|
||||
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
|
||||
import Editor from "./pages/Editor";
|
||||
import Survey from "./pages/Survey";
|
||||
import BugReport from "./pages/BugReport";
|
||||
import Shortcuts from "./pages/Shortcuts";
|
||||
import Templates from "./pages/Templates";
|
||||
import Home from "./pages/Home";
|
||||
import { CookiesProvider } from "react-cookie";
|
||||
import { useEffect } from "react";
|
||||
import LandingPage from "./pages/LandingPage";
|
||||
|
||||
const Wrapper = ({ children }) => {
|
||||
const location = useLocation();
|
||||
useEffect(() => {
|
||||
window.scroll(0, 0);
|
||||
}, [location.pathname]);
|
||||
return children;
|
||||
};
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<CookiesProvider>
|
||||
<Router>
|
||||
<BrowserRouter>
|
||||
<Wrapper>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/" element={<LandingPage />} />
|
||||
<Route path="/editor" element={<Editor />} />
|
||||
<Route path="/survey" element={<Survey />} />
|
||||
<Route path="/shortcuts" element={<Shortcuts />} />
|
||||
<Route path="/bug_report" element={<BugReport />} />
|
||||
<Route path="/templates" element={<Templates />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
</CookiesProvider>
|
||||
</Wrapper>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user