Skip to content

Commit 23ea810

Browse files
committed
fix: remove unstable key on CodeBlock to prevent flickering during streaming
The original Math.random() key caused React to remount the CodeBlock on every render. The PR's content-based key (language + content prefix) still changed every streaming token, causing the same flickering. Removing the key entirely lets React use positional identity, which is stable across re-renders while content streams in. Closes CopilotKit#2669
1 parent 789ab17 commit 23ea810

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

packages/react-ui/src/components/chat/Markdown.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const defaultComponents: Components = {
5959

6060
return (
6161
<CodeBlock
62-
key={Math.random()}
6362
language={(match && match[1]) || ""}
6463
value={String(children).replace(/\n$/, "")}
6564
{...props}

0 commit comments

Comments
 (0)