Replace useEffect with useLayoutEffect (#23)
This commit is contained in:
parent
6ab13a70d2
commit
13897e7217
@ -1,10 +1,10 @@
|
|||||||
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
|
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
|
||||||
|
import { useLayoutEffect } from "react";
|
||||||
import Editor from "./pages/Editor";
|
import Editor from "./pages/Editor";
|
||||||
import Survey from "./pages/Survey";
|
import Survey from "./pages/Survey";
|
||||||
import BugReport from "./pages/BugReport";
|
import BugReport from "./pages/BugReport";
|
||||||
import Shortcuts from "./pages/Shortcuts";
|
import Shortcuts from "./pages/Shortcuts";
|
||||||
import Templates from "./pages/Templates";
|
import Templates from "./pages/Templates";
|
||||||
import { useEffect, useLayoutEffect } from "react";
|
|
||||||
import LandingPage from "./pages/LandingPage";
|
import LandingPage from "./pages/LandingPage";
|
||||||
import SettingsContextProvider from "./context/SettingsContext";
|
import SettingsContextProvider from "./context/SettingsContext";
|
||||||
import useSettings from "./hooks/useSettings";
|
import useSettings from "./hooks/useSettings";
|
||||||
@ -82,7 +82,7 @@ function ThemedPage({ children }) {
|
|||||||
|
|
||||||
function RestoreScroll() {
|
function RestoreScroll() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
useEffect(() => {
|
useLayoutEffect(() => {
|
||||||
window.scroll(0, 0);
|
window.scroll(0, 0);
|
||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user