react-native-snap-carousel: Invariant Violation: VirtualizedList: The windowSize prop must be present and set to a value greater than 0
I am getting error as shown in the title react-native: 0.56.0 react-native-snap-carousel: ^3.7.2
const horizontalMargin = 20;
const slideWidth = 280;
const sliderWidth = Dimensions.get("window").width;
const itemWidth = slideWidth + horizontalMargin * 2;
const itemHeight = 100;
//
_renderItem = ({ item }) => {
return (
<View style={style.slide}>
<View style={style.slideInnerContainer} />
</View>
);
};
render() {
return (
<View style={style.container}>
<Carousel
data={[{ key: "1" }, { key: "2" }, { key: "3" }]}
renderItem={this._renderItem}
slideWidth={sliderWidth}
itemWidth={itemWidth}
/>
</View>
);
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 15 (4 by maintainers)
Ok I added
windowSize={1}
and it workedprovide both sliderWidth={400} itemWidth={400}
I created a fresh project, installed
react-native-snap-carousel
and simply ran the app with the code above, and I’m getting this error, I honestly don’t know what else to tell youI’m facing the same issue, and
windowSize={1}
did not fix it저는 속성을 잘못 지정해서 똑같은 에러가 발생했습니다.
slideWidth -> sliderWidth
for anyone reaching here this lib warns in case you do not specify sliderWidth and itemWidth while they are required in horizontal mode
actually if you take a look at prop types you can simply find them out
I believe that these lines
https://github.com/archriss/react-native-snap-carousel/blob/master/src/carousel/Carousel.js#L158 https://github.com/archriss/react-native-snap-carousel/blob/master/src/carousel/Carousel.js#L161
should use
console.error
because this way the user will see this error
instead of this weird complicated one which is from react native’s virtualized list
@bd-arc if this seems fine to you i’ll be happy to make a PR.
maybe you passed the “slideWidth” property as string, that expect a integer.
⚠️ You did not follow the contributing guidelines!
As stated in these:
Unless you provide a Snack example that reproduces the issue, we won’t be able to help you and the thread will be closed.
@bd-arc there you go https://github.com/archriss/react-native-snap-carousel/pull/528 ❤️