fix: rollup warning (#46024)

This commit is contained in:
二货爱吃白萝卜 2023-11-22 22:00:59 +08:00 committed by GitHub
parent 08a85d284c
commit 110e1b3ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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';
@ -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) => {