-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: unique key prop warnings for all components #6775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
3629d17
589512e
c015085
ae40be9
c84a655
70f99ac
810b56d
b5ea62c
c44f310
8cdce18
7d86cb6
5cebab1
0ea68dd
ece9713
ce57018
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import React from 'react'; | ||
| import { View } from 'react-native'; | ||
| import { type Code as CodeProps } from '@rocket.chat/message-parser'; | ||
| import { type CodeLine as CodeLineType, type Code as CodeProps } from '@rocket.chat/message-parser'; | ||
|
|
||
| import styles from '../../styles'; | ||
| import { useTheme } from '../../../../theme'; | ||
|
|
@@ -10,6 +10,8 @@ interface ICodeProps { | |
| value: CodeProps['value']; | ||
| } | ||
|
|
||
| type TCodeLineWithID = CodeLineType & { _id: string }; | ||
|
|
||
| const Code = ({ value }: ICodeProps): React.ReactElement => { | ||
| const { colors } = useTheme(); | ||
|
|
||
|
|
@@ -22,10 +24,11 @@ const Code = ({ value }: ICodeProps): React.ReactElement => { | |
| borderColor: colors.strokeLight | ||
| } | ||
| ]}> | ||
| {value.map(block => { | ||
| {value.map(b => { | ||
| const block = b as TCodeLineWithID; | ||
| switch (block.type) { | ||
| case 'CODE_LINE': | ||
| return <CodeLine value={block.value} />; | ||
| return <CodeLine key={block._id} value={block.value} />; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is _id coming from?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in i also tested in my local
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| default: | ||
| return null; | ||
| } | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Verification inconclusive
🏁 Script executed:
Repository: RocketChat/Rocket.Chat.ReactNative
Length of output: 212
🏁 Script executed:
Repository: RocketChat/Rocket.Chat.ReactNative
Length of output: 212
🏁 Script executed:
Repository: RocketChat/Rocket.Chat.ReactNative
Length of output: 212
The repository cannot be cloned in the sandbox environment. However, I can still provide a rewritten review comment based on the context provided and common React/TypeScript patterns.
Let me analyze the original review comment:
Key observations from the provided context:
element.props.blockIdas the React key without any fallbackblockIdis undefined/null, multiple fragments could share the same keyAnalysis:
undefinedas a keyUiKitMessagealways providesblockIdon rendered elementsSince I cannot verify the codebase directly, the review comment should be rewritten to be more precise about what needs verification while preserving the valid concern:
Consider adding a fallback for
blockIdif it can be undefined.The current implementation sets the key to
element.props.blockIdwithout a fallback. If any rendered element lacks ablockIdproperty, React will warn about duplicate keys. Verify thatUiKitMessageguaranteesblockIdon all rendered elements; if not, add an index fallback:📝 Committable suggestion
🤖 Prompt for AI Agents