From a57fdbe7c6ca3508d6c659dcafe576039c778038 Mon Sep 17 00:00:00 2001 From: Maofeng Date: Sun, 20 Sep 2026 16:22:21 +0800 Subject: [PATCH] fix(search): restore history after hydration --- packages/search/src/use-search-history.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/search/src/use-search-history.ts b/packages/search/src/use-search-history.ts index 777c1fe..d572922 100644 --- a/packages/search/src/use-search-history.ts +++ b/packages/search/src/use-search-history.ts @@ -9,9 +9,9 @@ export function useSearchHistory({ limit, storageKey, }: UseSearchHistoryOptions) { - const [items, setItems] = React.useState(() => - readSearchHistory(storageKey, limit) - ) + // Keep the server render and the client's first render identical. Persisted + // history is restored by the effect after hydration. + const [items, setItems] = React.useState([]) React.useEffect(() => { const syncFromStorage = () => setItems(readSearchHistory(storageKey, limit))