Skip to content

Commit

Permalink
feat:将index添加到到renderItem参数中
Browse files Browse the repository at this point in the history
  • Loading branch information
刘欢 committed Jan 7, 2025
1 parent 4627de9 commit a25df5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface ItemProps<ItemType> extends React.HTMLAttributes<any> {
item?: ItemType;
className?: string;
style?: React.CSSProperties;
renderItem?: (item: ItemType, order: number) => React.ReactNode;
renderItem?: (item: ItemType) => React.ReactNode;
responsive?: boolean;
// https://github.com/ant-design/ant-design/issues/35475
/**
Expand Down Expand Up @@ -66,7 +66,7 @@ function InternalItem<ItemType>(

// ================================ Render ================================
const childNode =
renderItem && item !== UNDEFINED ? renderItem(item, order) : children;
renderItem && item !== UNDEFINED ? renderItem(item) : children;

let overflowStyle: React.CSSProperties | undefined;
if (!invalidate) {
Expand Down
10 changes: 5 additions & 5 deletions src/Overflow.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { useState, useMemo, useCallback } from 'react';
import classNames from 'classnames';
import ResizeObserver from 'rc-resize-observer';
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
import * as React from 'react';
import { useCallback, useMemo, useState } from 'react';
import Item from './Item';
import useEffectState, { useBatcher } from './hooks/useEffectState';
import type { ComponentType } from './RawItem';
import RawItem from './RawItem';
import { OverflowContext } from './context';
import useEffectState, { useBatcher } from './hooks/useEffectState';

const RESPONSIVE = 'responsive' as const;
const INVALIDATE = 'invalidate' as const;
Expand All @@ -24,7 +24,7 @@ export interface OverflowProps<ItemType> extends React.HTMLAttributes<any> {
itemKey?: React.Key | ((item: ItemType) => React.Key);
/** Used for `responsive`. It will limit render node to avoid perf issue */
itemWidth?: number;
renderItem?: (item: ItemType, order: number) => React.ReactNode;
renderItem?: (item: ItemType) => React.ReactNode;
/** @private Do not use in your production. Render raw node that need wrap Item by developer self */
renderRawItem?: (item: ItemType, index: number) => React.ReactElement;
maxCount?: number | typeof RESPONSIVE | typeof INVALIDATE;
Expand Down Expand Up @@ -347,7 +347,7 @@ function Overflow<ItemType = any>(
{...itemSharedProps}
order={index}
key={key}
item={item}
item={{ ...item, index }}
renderItem={mergedRenderItem}
itemKey={key}
registerSize={registerSize}
Expand Down

0 comments on commit a25df5a

Please sign in to comment.