meliorence / meliorence/react-native-snap-carousel
Maximum update depth exceeded when loop is true
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Is this a bug report, a feature request, or a question?
Bug report
Have you followed the required steps before opening a bug report?
- I have read the guidelines regarding bug report.
- I have reviewed the documentation in its entirety, including the dedicated documentations 📚.
- I have searched for existing issues and made sure that the problem hasn't already been reported.
- I am using the latest plugin version.
- I am following the issue template closely in order to produce a useful bug report.
Have you made sure that it wasn't a React Native bug?
Yes
Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?
Both
(Write your answer here and specify the iOS/Android versions on which you've been able to reproduce the issue.)
Is the bug reproductible in a production environment (not a debug one)?
Yes
Environment
React: 17.0.1
React native: 0.64.2
react-native-snap-carousel: 3.9.1
Target Platform:
Android (10.0)
iOS (14.4)
Expected Behavior
Working loop mode
Actual Behavior
App crashes when loop passed as true

Reproducible Demo
(Paste the link to a Snack example in which the issue can be reproduced. Please follow the guidelines for providing a Minimal, Complete, and Verifiable example.)
Snack example doesnt work for react-native-snap-carousel.
It returns error: Cannot read property style of undefined
Steps to Reproduce
const CarouselImage: FC<CarouselImageProps> = ({item}) => {
const [isImageLoading, setIsImageLoading] = useState(true)
const onLoadStartImage = () => setIsImageLoading(true)
const onLoadEndImage = () => setIsImageLoading(false)
return (
<View style={styles.wrapper}>
<Image
style={styles.image}
source={{uri: item?.url}}
resizeMode="cover"
onLoadStart={onLoadStartImage}
onLoadEnd={onLoadEndImage}
/>
{isImageLoading && (
<ActivityIndicator
style={styles.imageLoader}
color={Colors.green}
size="large"
/>
)}
</View>
)
}
const restaurant_photos = [
{
"url": "https://diningout-dev.s3.amazonaws.com/images/restaurants/Bang Up To The Elephant!/e9535f1f-fb52-4f91-8713-0dd8408f1796"
},
{
"url": "https://diningout-dev.s3.amazonaws.com/images/restaurants/Bang Up To The Elephant!/8426d038-ad27-482a-8e56-98b1c0617ab5"
},
{
"url": "https://diningout-dev.s3.amazonaws.com/images/restaurants/Bang Up To The Elephant!/54d78642-3bd9-4a09-80b5-753fae26e922"
}
]
<Carousel
data={restaurant_photos}
keyExtractor={item => item.url?.toString()}
renderItem={({item}: {item: RestaurantPhoto}) => (
<CarouselImage item={item} />
)}
sliderWidth={Dimensions.get('window').width}
itemWidth={Dimensions.get('window').width}
sliderHeight={Dimensions.get('window').height * 0.35}
removeClippedSubviews={true}
loop={true}
inactiveSlideScale={1}
/>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the crash with the provided Carousel example using React 17.0.1, React Native 0.64.2, and react-native-snap-carousel 3.9.1 on both platforms. Trace the Carousel behavior when loop is true and verify that the maximum update depth error no longer occurs while loop mode works as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100