Skip to content
Snippets Groups Projects
Commit 78204ee7 authored by Aymeric Chaumont's avatar Aymeric Chaumont
Browse files

Merge branch 'handle_go_back_events' into 'main'

handle go back events

See merge request !42
parents 162fdeac 5a028bdc
Branches
No related tags found
1 merge request!42handle go back events
Pipeline #44348 passed
...@@ -41,6 +41,8 @@ export default function App() { ...@@ -41,6 +41,8 @@ export default function App() {
}, [reload]); }, [reload]);
useEffect(() => { useEffect(() => {
window.addEventListener("popstate", () => setReload(true));
let path = window.location.pathname.split("/"); let path = window.location.pathname.split("/");
if (restaurantsList && path.length >= 2 && path[1]) { if (restaurantsList && path.length >= 2 && path[1]) {
let name = decodeURIComponent(path[1]); let name = decodeURIComponent(path[1]);
...@@ -48,7 +50,11 @@ export default function App() { ...@@ -48,7 +50,11 @@ export default function App() {
if (filter) { if (filter) {
setSelection(filter[0]); setSelection(filter[0]);
} }
} else {
setSelection(null);
} }
return () => window.removeEventListener("popstate", () => setReload(true));
}, [restaurantsList]); }, [restaurantsList]);
useEffect(() => { useEffect(() => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment