Skip to content

Commit f8f30df

Browse files
committed
fix initial state including _depth
1 parent 098dccb commit f8f30df

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/strange-dodos-mix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/router": patch
3+
---
4+
5+
fix initial state including \_depth

src/routers/Router.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ export function Router(props: RouterProps): JSX.Element {
1212
if (isServer) return StaticRouter(props);
1313
const getSource = () => {
1414
const url = window.location.pathname.replace(/^\/+/, "/") + window.location.search;
15+
const state = window.history.state && window.history.state._depth && Object.keys(window.history.state).length === 1 ? undefined : window.history.state;
1516
return {
1617
value: url + window.location.hash,
17-
state: window.history.state
18+
state
1819
}
1920
};
2021
const beforeLeave = createBeforeLeave();

0 commit comments

Comments
 (0)