on master help sign in
fix: router allows back again
commite2f69174048a77dcda0a0f2921e067b76e5133f3 authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateMon 15 Jul 2019, 12:22 (7 years ago) parent938072c
1 file changed+7
src/lib/useRouter.js+7
src/lib/useRouter.js+7
@@ -88,6 +88,11 @@ export default function useRouter({
8888 window.scrollTo(0, 0);
8989 }, [routes]);
9090
91+ useEffect(() => {
92+ // on router mount, register new state with browser
93+ window.history.pushState(null, null, null);
94+ }, []);
95+
9196 // capture browser pop in primary router
9297 useEffect(() => {
9398 // store the previous onpopstate handler
@@ -103,6 +108,8 @@ export default function useRouter({
103108
104109 // on pop, tell the browser of a new state to avoid giving the user
105110 // 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
106113 window.history.pushState(null, null, null);
107114
108115 // then update our local state for rendering