Skip to content

Commit ff25af3

Browse files
committed
fix(web): fix React 19 key prop warning in typescript-viewer
Destructure key prop from getLineProps and getTokenProps before spreading to avoid React warning about key props in spread objects.
1 parent 7f52842 commit ff25af3

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

web/src/components/agent/typescript-viewer.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,19 @@ export function TypeScriptViewer({
144144
className={`${highlightClassName} bg-muted p-4 rounded-lg overflow-x-auto text-sm max-h-[600px] overflow-y-auto`}
145145
style={{ ...style, backgroundColor: 'transparent' }}
146146
>
147-
{tokens.map((line, i) => (
148-
<div key={i} {...getLineProps({ line })}>
149-
{line.map((token, key) => (
150-
<span key={key} {...getTokenProps({ token, key })} />
151-
))}
152-
</div>
153-
))}
147+
{tokens.map((line, i) => {
148+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
149+
const { key: _lineKey, ...lineProps } = getLineProps({ line })
150+
return (
151+
<div key={i} {...lineProps}>
152+
{line.map((token, tokenIndex) => {
153+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
154+
const { key: _tokenKey, ...tokenProps } = getTokenProps({ token, key: tokenIndex })
155+
return <span key={tokenIndex} {...tokenProps} />
156+
})}
157+
</div>
158+
)
159+
})}
154160
</pre>
155161
)}
156162
</Highlight>

0 commit comments

Comments
 (0)