Skip to content

Commit add009b

Browse files
sadpandajoeclaude
andcommitted
refactor(explore): simplify React keys in ViewQueryModal to match codebase patterns
Changed from content-based keys (item.query || item.error) to index-based keys for the Fragment elements in ViewQueryModal. This aligns with established Superset patterns (e.g., MarshmallowErrorMessage.tsx) for displaying static API response data. Both approaches are technically correct for static data, but index-based is simpler and more consistent. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7620bc8 commit add009b

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

superset-frontend/src/explore/components/controls/ViewQueryModal.tsx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,21 @@ const ViewQueryModal: FC<Props> = ({ latestQueryFormData }) => {
8989

9090
return (
9191
<ViewQueryModalContainer>
92-
{result.map((item, index) => {
93-
// Use content-based key when available, fall back to index
94-
const key = item.query || item.error || `result-${index}`;
95-
return (
96-
<Fragment key={key}>
97-
{item.error && (
98-
<Alert type="error" message={item.error} closable={false} />
99-
)}
100-
{item.query && (
101-
<ViewQuery
102-
datasource={latestQueryFormData.datasource}
103-
sql={item.query}
104-
language={item.language}
105-
/>
106-
)}
107-
</Fragment>
108-
);
109-
})}
92+
{result.map((item, index) => (
93+
// Static API response data - index is appropriate for keys
94+
<Fragment key={index}>
95+
{item.error && (
96+
<Alert type="error" message={item.error} closable={false} />
97+
)}
98+
{item.query && (
99+
<ViewQuery
100+
datasource={latestQueryFormData.datasource}
101+
sql={item.query}
102+
language={item.language}
103+
/>
104+
)}
105+
</Fragment>
106+
))}
110107
</ViewQueryModalContainer>
111108
);
112109
};

0 commit comments

Comments
 (0)