1.0.3 • Published 6 months ago
react-native-stack-carousel v1.0.3
Example
Here's a basic example of how to use the Carousel
component:
import React from "react";
import { View, StyleSheet } from "react-native";
import { useSharedValue } from "react-native-reanimated";
import Carousel from "react-native-stack-carousel";
const App = () => {
const currentIndex = useSharedValue(0);
const animatedValue = useSharedValue(0);
const IMAGES = [
{ id: 1, uri: "https://example.com/image1.jpg" },
{ id: 2, uri: "https://example.com/image2.jpg" },
{ id: 3, uri: "https://example.com/image3.jpg" },
];
return (
<View style={styles.container}>
{IMAGES.map((item, index) => (
<Carousel
item={item}
index={index}
key={item.id}
maxVisibleItems={6}
prevIndex={prevIndex}
dataLength={IMAGES.length}
currentIndex={currentIndex}
animatedValue={animatedValue}
imageStyle={styles.imageStyle}
direction="vertical-top-variant2"
>
<View style={styles.textContainer}>
<Text style={styles.text}>{item?.value}</Text>
</View>
</Carousel>
))}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
},
});
export default App;