Skip to content

Commit

Permalink
Fix quick links key warning (#3049)
Browse files Browse the repository at this point in the history
This was giving a warning that the <td> should have a key.

I looked at the code and it seemed stupid to have the <td>
in the QuickLinks return to begin with, so I changed it to return
just the links. That solves the warning, but it probably shouldn't
(possibly a React bug?) so to be actually safe, this also creates
a React fragment to return instead of the array.
  • Loading branch information
reosarevok committed Dec 6, 2023
1 parent 277e1a6 commit e56e14a
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions root/edit/components/ListHeader.js
Expand Up @@ -22,13 +22,13 @@ type Props = {
+username?: string,
};

const QuickLinksSection = ({
const QuickLinks = ({
entity,
isSearch = false,
page,
refineUrlArgs,
username,
}: Props): React$Element<'td'> => {
}: Props): React$Element<React$FragmentType> => {
const $c = React.useContext(CatalystContext);
const isSecureConnection = $c.req.secure;
const protocol = isSecureConnection ? 'https://' : 'http://';
Expand Down Expand Up @@ -173,16 +173,14 @@ const QuickLinksSection = ({
</a>,
);
}
return (
<td>
{quickLinks.reduce((accum: Array<React$Node>, link, index) => {
accum.push(link);
if (index < (quickLinks.length - 1)) {
accum.push(' | ');
}
return accum;
}, [])}
</td>
return React.createElement(React.Fragment, null, ...quickLinks.reduce(
(accum: Array<React$Node>, link, index) => {
accum.push(link);
if (index < (quickLinks.length - 1)) {
accum.push(' | ');
}
return accum;
}, [])
);
};

Expand All @@ -198,13 +196,15 @@ const ListHeader = ({
<th>
{l('Quick links:')}
</th>
<QuickLinksSection
entity={entity}
isSearch={isSearch}
page={page}
refineUrlArgs={refineUrlArgs}
username={username}
/>
<td>
<QuickLinks
entity={entity}
isSearch={isSearch}
page={page}
refineUrlArgs={refineUrlArgs}
username={username}
/>
</td>
</tr>
<tr>
<th>
Expand Down

0 comments on commit e56e14a

Please sign in to comment.