Skip to content

Commit

Permalink
fix: rollup warning (ant-design#46024)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ authored Nov 22, 2023
1 parent 08a85d2 commit 110e1b3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions components/card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import classNames from 'classnames';
import type { Tab } from 'rc-tabs/lib/interface';
import omit from 'rc-util/lib/omit';
import * as React from 'react';

import { ConfigContext } from '../config-provider';
import useSize from '../config-provider/hooks/useSize';
import Skeleton from '../skeleton';
Expand Down Expand Up @@ -47,12 +48,18 @@ export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 't
}

function getAction(actions: React.ReactNode[]): React.ReactNode[] {
return actions.map<React.ReactNode>((action, index) => (
// eslint-disable-next-line react/no-array-index-key
<li style={{ width: `${100 / actions.length}%` }} key={`action-${index}`}>
<span>{action}</span>
</li>
));
return actions.map<React.ReactNode>((action, index) => {
// Move this out since eslint not allow index key
// And eslint-disable makes conflict with rollup
// ref https://github.com/ant-design/ant-design/issues/46022
const key = `action-${index}`;

return (
<li style={{ width: `${100 / actions.length}%` }} key={key}>
<span>{action}</span>
</li>
);
});
}

const Card = React.forwardRef<HTMLDivElement, CardProps>((props, ref) => {
Expand Down

0 comments on commit 110e1b3

Please sign in to comment.