-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: replace index-only keys with stable composite keys in mapped lists #3777
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: canary
Are you sure you want to change the base?
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -402,7 +402,7 @@ export const DockerLogsId: React.FC<Props> = ({ | |||||
| {filteredLogs.length > 0 ? ( | ||||||
| filteredLogs.map((filteredLog: LogLine, index: number) => ( | ||||||
| <TerminalLine | ||||||
| key={index} | ||||||
| key={`${filteredLog.rawTimestamp ?? ""}-${index}`} | ||||||
|
||||||
| key={`${filteredLog.rawTimestamp ?? ""}-${index}`} | |
| key={`${filteredLog.rawTimestamp ?? ""}-${filteredLog.message ?? ""}`} |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -356,7 +356,7 @@ export const Configure2FA = () => { | |||||
| <div className="grid grid-cols-2 gap-2"> | ||||||
| {backupCodes.map((code, index) => ( | ||||||
| <code | ||||||
| key={index} | ||||||
| key={`${code}-${index}`} | ||||||
|
||||||
| key={`${code}-${index}`} | |
| key={code} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -401,7 +401,7 @@ export const Enable2FA = () => { | |
| <div className="grid grid-cols-2 gap-2"> | ||
| {backupCodes.map((code, index) => ( | ||
| <code | ||
| key={index} | ||
| key={`${code}-${index}`} | ||
| className="bg-muted p-2 rounded text-sm font-mono" | ||
|
Comment on lines
403
to
405
|
||
| > | ||
| {code} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -60,7 +60,11 @@ export const DrawerLogs = ({ isOpen, onClose, filteredLogs }: Props) => { | |||||
| {" "} | ||||||
| {filteredLogs.length > 0 ? ( | ||||||
| filteredLogs.map((log: LogLine, index: number) => ( | ||||||
| <TerminalLine key={index} log={log} noTimestamp /> | ||||||
| <TerminalLine | ||||||
| key={`${log.rawTimestamp ?? ""}-${index}`} | ||||||
|
||||||
| key={`${log.rawTimestamp ?? ""}-${index}`} | |
| key={JSON.stringify(log)} |
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.
Both mapped log lists use keys that include
index, which will change when logs are filtered/toggled and can cause unnecessary remounting. Prefer keys based on log identity only (e.g.,rawTimestamp+messageor a stable parsed id/lineNumber) to keep rows stable.