Skip to content

Commit 84a0152

Browse files
committed
change render to support components, functions and JSX elements
1 parent ba25a3a commit 84a0152

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/Swiper.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ export default function Swiper({style, data, isStaticPills, ...rest}) {
5050
};
5151
const keyExtractor = (item, index) => String(index);
5252
const renderItem = ({item, index}) => (
53-
<View key={index} style={{width}}>
54-
{item.component}
53+
<View style={{width}}>
54+
{typeof item.component !== 'function' && item.component}
55+
{typeof item.component === 'function' && item.component({
56+
index,
57+
...(item.props || {}),
58+
})}
5559
</View>
5660
);
5761

0 commit comments

Comments
 (0)