Skip to content

Commit 74b67c3

Browse files
committed
fix: hoist groupedPages to module scope in DocsSearch
docsPages is constant, no need to recompute grouping on every render
1 parent dcb2254 commit 74b67c3

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

frontend/src/components/docs/DocsSearch.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ const docsPages: DocPage[] = [
162162
},
163163
]
164164

165+
// Pre-compute grouped pages at module level since docsPages is constant
166+
const groupedPages = docsPages.reduce((acc, page) => {
167+
if (!acc[page.category]) {
168+
acc[page.category] = []
169+
}
170+
acc[page.category].push(page)
171+
return acc
172+
}, {} as Record<string, DocPage[]>)
173+
165174
export function DocsSearch() {
166175
const [open, setOpen] = useState(false)
167176
const navigate = useNavigate()
@@ -183,15 +192,6 @@ export function DocsSearch() {
183192
command()
184193
}, [])
185194

186-
// Group pages by category
187-
const groupedPages = docsPages.reduce((acc, page) => {
188-
if (!acc[page.category]) {
189-
acc[page.category] = []
190-
}
191-
acc[page.category].push(page)
192-
return acc
193-
}, {} as Record<string, DocPage[]>)
194-
195195
return (
196196
<>
197197
<button

0 commit comments

Comments
 (0)