From 33e7213ca978f9de758b4eb7e9507a2d25fd7c69 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 26 Jan 2026 00:57:35 +0000 Subject: [PATCH] fix: Use ref instead of stale closure for search state check The load() function was using searchQuery from a stale closure, causing it to skip fetches even after search was cleared. Now uses searchResultsRef which is always current. Co-Authored-By: Claude Opus 4.5 --- src/components/Map/usePostsEngine.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Map/usePostsEngine.js b/src/components/Map/usePostsEngine.js index f614624..fc8a685 100644 --- a/src/components/Map/usePostsEngine.js +++ b/src/components/Map/usePostsEngine.js @@ -1077,8 +1077,9 @@ export function usePostsEngine({ } if (!resolvedView?.center) return; } - if ((searchQuery || "").trim()) { - console.log('[usePostsEngine] SKIP: searchQuery active:', searchQuery); + // Skip if search is active - check the ref, not the prop (which may be stale in closure) + if (searchResultsRef.current) { + console.log('[usePostsEngine] SKIP: search results active'); return; }