perf: wrap ToolCall, CodeBlock, ThinkingBlock, ImageBlock in React.memo

Prevents unnecessary re-renders of these frequently rendered child
components when parent message list updates but individual props
haven't changed.
This commit is contained in:
Nicolas Varrot
2026-02-22 21:03:31 +00:00
parent 4163124c6a
commit 9faa5014a6
4 changed files with 12 additions and 12 deletions

View File

@@ -1,8 +1,8 @@
import { useState } from 'react';
import { useState, memo } from 'react';
import { ChevronRight, ChevronDown, Brain } from 'lucide-react';
import { useT } from '../hooks/useLocale';
export function ThinkingBlock({ text }: { text: string }) {
export const ThinkingBlock = memo(function ThinkingBlock({ text }: { text: string }) {
const t = useT();
const [open, setOpen] = useState(false);
@@ -25,4 +25,4 @@ export function ThinkingBlock({ text }: { text: string }) {
)}
</div>
);
}
});