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>
);
}
鈿狅笍 You did not follow the contributing guidelines!
As stated in these:
You need to fill out the issue template. This step is mandatory! Not doing so will result in your issue getting closed. Don't take this personally if this happens, and feel free to open a new issue once you've gathered all the information required by the template.
Unless you provide a Snack example that reproduces the issue, we won't be able to help you and the thread will be closed.
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 you
Ok I added windowSize={1} and it worked
I'm facing the same issue, and windowSize={1} did not fix it
maybe you passed the "slideWidth" property as string, that expect a integer.
provide both
sliderWidth={400}
itemWidth={400}
for anyone reaching here this lib warns in case you do not specify sliderWidth and itemWidth while they are required in horizontal mode
react-native-snap-carousel: You need to specify both `sliderWidth` and `itemWidth` for horizontal carousels
actually if you take a look at prop types you can simply find them out
itemWidth: PropTypes.number, // required for horizontal carousel
itemHeight: PropTypes.number, // required for vertical carousel
sliderWidth: PropTypes.number, // required for horizontal carousel
sliderHeight: PropTypes.number, // required for vertical carousel
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.
@bardiarastin You're totally right! Looking forward to seeing that PR ;-)
@bd-arc there you go https://github.com/archriss/react-native-snap-carousel/pull/528 <3
I'm facing the same issue, and
windowSize={1}did not fix it
hi @gautham20 kill the app and try restarting it, it worked for me. hope this helps
Any solution to this problem

I always get this error first time, when I open this page.
I have to restart application, and its working, Any solution to this problem.
Is there any problem on initialise first time.
FWIW I had this issue when I was trying to use em for slide width. Changing to a Number fixes the issue.
Most helpful comment
Ok I added
windowSize={1}and it worked