chore: make < TimelineItem /> a bit lighter, drop unneeded omit.js and defaultProps (#27961)

This commit is contained in:
Eugene Matvejev 2020-11-24 12:19:35 +00:00 committed by GitHub
parent 41a6c655bf
commit 683eec118b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
import * as React from 'react';
import classNames from 'classnames';
import omit from 'omit.js';
import { ConfigContext } from '../config-provider';
export interface TimelineItemProps {
@ -20,18 +19,18 @@ export interface TimeLineItemProps extends TimelineItemProps {
__deprecated_do_not_use_it__?: any; // eslint-disable-line camelcase
}
const TimelineItem: React.FC<TimelineItemProps> = props => {
const TimelineItem: React.FC<TimelineItemProps> = ({
prefixCls: customizePrefixCls,
className,
color = 'blue',
dot,
pending = false,
position, /** dead, but do not pass in <li {...omit()} */
label,
children,
...restProps
}) => {
const { getPrefixCls } = React.useContext(ConfigContext);
const {
prefixCls: customizePrefixCls,
className,
color,
children,
pending,
dot,
label,
...restProps
} = props;
const prefixCls = getPrefixCls('timeline', customizePrefixCls);
const itemClassName = classNames(
@ -49,7 +48,7 @@ const TimelineItem: React.FC<TimelineItemProps> = props => {
});
return (
<li {...omit(restProps, ['position'])} className={itemClassName}>
<li {...restProps} className={itemClassName}>
{label && <div className={`${prefixCls}-item-label`}>{label}</div>}
<div className={`${prefixCls}-item-tail`} />
<div
@ -63,10 +62,4 @@ const TimelineItem: React.FC<TimelineItemProps> = props => {
);
};
TimelineItem.defaultProps = {
color: 'blue',
pending: false,
position: '',
};
export default TimelineItem;