我有一个平面列表组件,我想让它自动滚动。
<FlatList
contentContainerStyle={{}}
data={banners}
renderItem={(item) => (
<Image source={{ uri: item.item }} style={styles.image} />
)}
horizontal
showsHorizontalScrollIndicator={false}
snapToInterval={width}
snapToAlignment={'center'}
decelerationRate={'fast'}
/>
这是到目前为止我需要什么属性而不是 setInterval 的组件还有其他想法吗?
我搜索了去年的一些旧解决方案,这些解决方案已经过时了。我想要一些代码行数更少并且更容易应用的东西。
如果您想要最少的代码行并且不想自己处理触发滚动,则应该使用像这样的轮播包:
https://github.com/dohooo/react-native-reanimated-carousel#readme