Skip to content

Commit

Permalink
Merge pull request #184 from kkeene1/back-to-slug
Browse files Browse the repository at this point in the history
Setting window history state on initial page load
  • Loading branch information
tj-kev committed Oct 3, 2021
2 parents c8942d3 + 1a6424d commit 0b864e6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export function RouterProvider({
};
}, [protocol, host, route.asPath, params]);

useEffect(() => {
// On initial page load, replace history state with format expected by router
window.history.replaceState(route, null, route.asPath);
}, [])

useEffect(() => {
async function loadNewPage() {
const { href, asPath } = route;
Expand Down

0 comments on commit 0b864e6

Please sign in to comment.