mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
6a5e7ded43
* refactor: remove IE compatible logic * fix: fix * fix: fix * fix: fix
32 lines
752 B
TypeScript
32 lines
752 B
TypeScript
import * as React from 'react';
|
|
|
|
import { SpaceContext } from './context';
|
|
import type { SpaceContextType } from './context';
|
|
|
|
export interface ItemProps {
|
|
className: string;
|
|
children: React.ReactNode;
|
|
index: number;
|
|
split?: React.ReactNode;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
const Item: React.FC<ItemProps> = ({ className, index, children, split, style }) => {
|
|
const { latestIndex } = React.useContext<SpaceContextType>(SpaceContext);
|
|
|
|
if (children === null || children === undefined) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<div className={className} style={style}>
|
|
{children}
|
|
</div>
|
|
{index < latestIndex && split && <span className={`${className}-split`}>{split}</span>}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Item;
|