Skip to content

Commit 5bb5917

Browse files
perf(web): the code block language picker compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a702563 commit 5bb5917

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

‎apps/web/src/components/chat/ComposerCodeBlockLanguagePicker.tsx‎

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CheckIcon, ChevronDownIcon } from "lucide-react";
2-
import { useMemo, useState } from "react";
2+
import { useState } from "react";
33

44
import {
55
CODE_BLOCK_LANGUAGES,
@@ -36,20 +36,15 @@ export function ComposerCodeBlockLanguagePicker(props: {
3636
}) {
3737
const [query, setQuery] = useState("");
3838
const current = codeLanguageEntry(props.language)?.id ?? props.language;
39-
const items = useMemo<CodeBlockLanguage[]>(
40-
() =>
41-
CODE_BLOCK_LANGUAGES.some((entry) => entry.id === current)
42-
? [...CODE_BLOCK_LANGUAGES]
43-
: [{ id: current, label: current }, ...CODE_BLOCK_LANGUAGES],
44-
[current],
45-
);
46-
const filteredItems = useMemo(() => {
47-
const needle = query.trim().toLowerCase();
48-
if (!needle) return items;
49-
return items.filter(
50-
(entry) => entry.label.toLowerCase().includes(needle) || entry.id.includes(needle),
51-
);
52-
}, [items, query]);
39+
const items: CodeBlockLanguage[] = CODE_BLOCK_LANGUAGES.some((entry) => entry.id === current)
40+
? [...CODE_BLOCK_LANGUAGES]
41+
: [{ id: current, label: current }, ...CODE_BLOCK_LANGUAGES];
42+
const needle = query.trim().toLowerCase();
43+
const filteredItems = needle
44+
? items.filter(
45+
(entry) => entry.label.toLowerCase().includes(needle) || entry.id.includes(needle),
46+
)
47+
: items;
5348
const selected = items.find((entry) => entry.id === current) ?? null;
5449

5550
return (

0 commit comments

Comments
 (0)