fix(navigation): cache getServerSnapshot fallback in useSearchParams (#79)
* fix(navigation): cache getServerSnapshot fallback in useSearchParams
useSyncExternalStore compares snapshots with Object.is. The previous
getServerSnapshot returned `new URLSearchParams()` on every call when no
server context was available, producing a new object reference each time
and triggering an infinite re-render loop in React.
Fix: introduce a module-level `_cachedServerSearchParams` that is
allocated once and reused, matching the same referential-stability
pattern already used by `getSearchParamsSnapshot` for the client
snapshot.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Refactor cached search params and pathname logic
Refactor cached variables for search params and pathname for better referential stability. Consolidate logic to avoid infinite re-renders.
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Fred K. Schott <622227+FredKSchott@users.noreply.github.com>