+1
-1
| { | ||
| "name": "wouter", | ||
| "version": "3.8.0", | ||
| "version": "3.8.1", | ||
| "description": "Minimalist-friendly ~1.5KB router for React", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+8
-5
@@ -149,5 +149,8 @@ import { parse as parsePattern } from "regexparam"; | ||
| // when `ssrPath` contains a `?` character, we can extract the search from it | ||
| const [path, search] = props.ssrPath?.split("?") ?? []; | ||
| if (search) (props.ssrSearch = search), (props.ssrPath = path); | ||
| // when `ssrPath` contains a `?` character, we can extract the search from it. | ||
| // also, ensure ssrSearch is always defined when ssrPath is provided, so that | ||
| // useSearch behavior matches usePathname (proper SSR hydration when client | ||
| // renders <Router> without props after server rendered with ssrPath/ssrSearch) | ||
| const [path, search = props.ssrSearch ?? ""] = props.ssrPath?.split("?") ?? []; | ||
| if (path) props.ssrSearch = search, props.ssrPath = path; | ||
@@ -178,4 +181,4 @@ // hooks can define their own `href` formatter (e.g. for hash location) | ||
| ? /* base is special case, it is appended to the parent's base */ | ||
| parent[k] + (props[k] || "") | ||
| : props[k] || parent[k]; | ||
| parent[k] + (props[k] ?? "") | ||
| : props[k] ?? parent[k]; | ||
@@ -182,0 +185,0 @@ if (prev === next && option !== next[k]) { |
@@ -36,2 +36,5 @@ import { useSyncExternalStore } from "./react-deps.js"; | ||
| currentSearch, | ||
| // != null checks for both null and undefined, but allows empty string "" | ||
| // This allows proper hydration: server renders with ssrSearch="?foo", | ||
| // client hydrates with just <Router /> and reads from location.search | ||
| ssrSearch != null ? () => ssrSearch : currentSearch | ||
@@ -45,2 +48,5 @@ ); | ||
| currentPathname, | ||
| // != null checks for both null and undefined, but allows empty string "" | ||
| // This allows proper hydration: server renders with ssrPath="/foo", | ||
| // client hydrates with just <Router /> and reads from location.pathname | ||
| ssrPath != null ? () => ssrPath : currentPathname | ||
@@ -47,0 +53,0 @@ ); |
71497
1.01%891
1.02%