a simple swipeable carousel which anchor two sides
npm install react-native-anchor-carouselA simple swipeable carousel for React Native which anchor two side of list.
sh
$ npm install react-native-anchor-carousel
`
`sh
$ yarn add react-native-anchor-carousel
`
\
For older version, install 3.1.2
`sh
$ npm install react-native-anchor-carousel@3.1.2
`
`sh
$ yarn add react-native-anchor-carousel@3.1.2
`$3



`javascript
import Carousel from 'react-native-anchor-carousel';
const {width: windowWidth} = Dimensions.get('window');
const styles = StyleSheet.create({
carousel: {
flexGrow: 0,
height: 150,
}
});
`\
Hook Component version:
`javascript
const carouselRef = React.useRef(null);
renderItem = ({item, index}) => {
return (
style={styles.item}
onPress={() => {
carouselRef.current.scrollToIndex(index);
}}>
...
);
}
return ( ref={carouselRef}
data={Array(3).fill(0)}
renderItem={renderItem}
style={styles.carousel}
itemWidth={windowWidth * 0.8}
containerWidth={windowWidth}
separatorWidth={0}
/>)
`
\
Traditional Class Component version:
`javascript
renderItem = ({item, index}) => {
return (
style={styles.item}
onPress={() => {
this.numberCarousel.scrollToIndex(index);
}}>
...
);
};render() {
return (
style={styles.carousel}
ref={c => {
this.numberCarousel = c;
}}
data={Array(3).fill(0)}
renderItem={this.renderItem}
itemWidth={windowWidth * 0.8}
separatorWidth={0}
containerWidth={windowWidth}
/>
);
}
`
$3
This component currently just support only carousel for horizontal side carousel
From version 2.2.0.
\
It is now supported __Flatlist__ props
from version 3.0.0 Change scroll behavior of previous versions
\
From version 4.0.0 it has been moved to Functional component and fix separator bug
| Props | Description | Type | Default | Required |
| ------ | ------ | ------| -----| ----|
| data | Array of data for rendering | Array | [] | Yes|
| renderItems | take each item from data and renders it. Function receives one agrument {item,index}` and must return as React.Element | Function | () => {} | Yes |
License
----
MIT
Free Software, Hell Yeah!