on master help sign in
fix: router allows back again
e2f6917Matt Condon (shrugs)
src/lib/useRouter.js+7
@@ -88,6 +88,11 @@ export default function useRouter({
88 window.scrollTo(0, 0);
88 window.scrollTo(0, 0);
89 }, [routes]);
89 }, [routes]);
90
90
91+ useEffect(() => {
92+ // on router mount, register new state with browser
93+ window.history.pushState(null, null, null);
94+ }, []);
95+
91 // capture browser pop in primary router
96 // capture browser pop in primary router
92 useEffect(() => {
97 useEffect(() => {
93 // store the previous onpopstate handler
98 // store the previous onpopstate handler
@@ -103,6 +108,8 @@ export default function useRouter({
103
108
104 // on pop, tell the browser of a new state to avoid giving the user
109 // on pop, tell the browser of a new state to avoid giving the user
105 // the ability to go forward
110 // the ability to go forward
111+ // TODO: allow the user to go forward by storing our data in history
112+ // and using the url for other state
106 window.history.pushState(null, null, null);
113 window.history.pushState(null, null, null);
107
114
108 // then update our local state for rendering
115 // then update our local state for rendering