Skip to content

if high number of slides scrolling/sliding not working properly #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maghamvinod opened this issue Apr 3, 2024 · 5 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@maghamvinod
Copy link

No description provided.

@maghamvinod maghamvinod added the bug Something isn't working label Apr 3, 2024
Copy link

dosubot bot commented Apr 3, 2024

Hey there @maghamvinod! Long time no see in the issue realm. Hope you're doing well amidst all the coding adventures! 😄👋

Based on the issues you've described, it seems like you're encountering performance issues when dealing with a high number of slides in the react-native-reanimated-carousel component. This is a common challenge when dealing with large lists of data in React Native.

One of the solutions suggested in a similar issue #207 is to set a value for the windowSize prop. This prop helps in rendering just a couple of elements of any large list, keeping a good frame rate. The user found better results giving it a value between 3 -> 5. You might want to try this with your own implementation and compare it against the base use case.

Another approach to handle this issue is to implement a lazy loading mechanism. The react-native-reanimated-carousel provides a LazyView component that can be used to only render the slides that are currently in view or near the view, thus reducing the load and potentially fixing the scrolling or sliding issues.

Here's an example of how you might modify a carousel item to use LazyView:

import React, { useState, useEffect } from 'react';
import { View, Text } from 'react-native';
import { LazyView } from './LazyView'; // Adjust the import path as necessary

// Example carousel item component
const CarouselItem = ({ index, isActive }) => {
  // isActive is a prop to determine if this item is currently active (visible)
  return (
    <LazyView shouldUpdate={isActive}>
      <View>
        <Text>Slide {index}</Text>
      </View>
    </LazyView>
  );
};

export default CarouselItem;

In this example, isActive would be a prop passed to each CarouselItem based on the carousel's current index and the item's index. You would need to implement the logic to calculate isActive based on the carousel's behavior and pass it accordingly.

The LazyView component in the react-native-reanimated-carousel codebase is designed to conditionally render its children based on the shouldUpdate prop. If shouldUpdate is true, it renders its children. If shouldUpdate is false, it renders nothing (an empty fragment). This behavior allows for optimization by preventing unnecessary rendering of components that do not need to be updated. You can find more about this in the LazyView.tsx file.

Please try these solutions and let me know if they help resolve your issue. If not, could you provide more specific details about your implementation for further assistance?

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@maghamvinod
Copy link
Author

I used windowsize property also, but not exact animation is coming. If I scroll to next views the previous slides also coming.

@maghamvinod
Copy link
Author

maghamvinod commented Apr 3, 2024

Hi,
I tried window size 3,5 but what happening is the previous widows coming after 5th slide also

@maghamvinod
Copy link
Author

Hi @dohooo ,

any update on this. Only android side having issue. Ios side it is fine.

Copy link

dosubot bot commented Feb 17, 2025

Hi, @maghamvinod. I'm Dosu, and I'm helping the react-native-reanimated-carousel team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You reported scrolling issues with react-native-reanimated-carousel when handling many slides, particularly on Android.
  • Suggested solutions included using the windowSize prop and implementing lazy loading with LazyView.
  • You mentioned that the windowSize prop did not resolve the issue, as previous slides still appear after scrolling past the fifth slide.
  • The issue is specific to Android, with iOS functioning correctly.

Next Steps:

  • Could you confirm if this issue is still relevant with the latest version of the react-native-reanimated-carousel? If so, please comment to keep the discussion open.
  • If there is no further activity, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 17, 2025
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2025
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants