mirror of
https://github.com/hanzo-apps/hanzo.ai.git
synced 2026-10-29 07:20:43 +00:00
Every import, the catalog pin and the docs name @hanzo/app and github.com/hanzoai/app. lib/rooms.ts is lib/app.ts and components/rooms.tsx is components/app.tsx.
19 lines
729 B
TypeScript
19 lines
729 B
TypeScript
'use client'
|
|
|
|
import { useMemo, useSyncExternalStore } from 'react'
|
|
|
|
/** Nothing to subscribe to: a page's own query changes only by a navigation, which renders it again. */
|
|
const NEVER = () => () => {}
|
|
|
|
/**
|
|
* The page's query as the browser has it: empty in the prerendered markup and
|
|
* on the first client paint, so hydration matches, and the real one on the
|
|
* render hydration already performs (the shape of @hanzo/app `useHydrated`).
|
|
* It asks for no Suspense boundary, which `useSearchParams` does in a static
|
|
* export.
|
|
*/
|
|
export function useQuery(): URLSearchParams {
|
|
const search = useSyncExternalStore(NEVER, () => window.location.search, () => '')
|
|
return useMemo(() => new URLSearchParams(search), [search])
|
|
}
|