Skip to content

Commit

Permalink
fix initial state including _depth
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Sep 13, 2024
1 parent 098dccb commit f8f30df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/strange-dodos-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/router": patch
---

fix initial state including \_depth
3 changes: 2 additions & 1 deletion src/routers/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export function Router(props: RouterProps): JSX.Element {
if (isServer) return StaticRouter(props);
const getSource = () => {
const url = window.location.pathname.replace(/^\/+/, "/") + window.location.search;
const state = window.history.state && window.history.state._depth && Object.keys(window.history.state).length === 1 ? undefined : window.history.state;
return {
value: url + window.location.hash,
state: window.history.state
state
}
};
const beforeLeave = createBeforeLeave();
Expand Down

0 comments on commit f8f30df

Please sign in to comment.