Skip to content

Commit

Permalink
chore(List): Enhance renderItem props.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Apr 21, 2020
1 parent b93bb0a commit f811dcb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const noop = () => null;
*/
export interface ListRenderItemInfoCustom<ItemT> {
item: ItemT;
index?: number;
index: number;
separators?: {
highlight: () => void;
unhighlight: () => void;
Expand Down Expand Up @@ -105,7 +105,7 @@ export default class List extends Component<ListProps, ListState> {
<View {...otherProps}>
{header}
{(renderItem && (!data || data.length == 0) || (!renderItem && (!children || React.Children.toArray(children).length === 0))) && otherProps.ListEmptyComponent}
{(props.data || []).map((item, idx) => React.cloneElement(props.renderItem({ item }) || <View />, {key: idx}))}
{(props.data || []).map((item, idx) => React.cloneElement(props.renderItem({ item, index: idx }) || <View />, {key: idx}))}
</View>
)
}
Expand Down

0 comments on commit f811dcb

Please sign in to comment.