Skip to content
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

perf: useRecyclingEffect + useRecyclingState performance issues #63

Open
mbilenko-florio opened this issue Jan 12, 2025 · 0 comments
Open

Comments

@mbilenko-florio
Copy link
Contributor

mbilenko-florio commented Jan 12, 2025

I've found out that I'm getting extra Card renders of the when using useRecylingState

  console.log("Rendering", item.id);
    // A callback when the item is recycled
    useRecyclingEffect?.(({ item, prevItem, index, prevIndex }) => {
        console.log("Recycled", item.id);
        refSwipeable?.current?.close();
    });

Double renderings are happening because useRecyclingEffect is happening to often, and useRecyclingState is using useRecyclingEffect inside. From my understanding useRecylingEffect should happen only after screen has left the screen, and not on the first render.
Here is respective logs:

 (NOBRIDGE) LOG  Rendering 0
 (NOBRIDGE) LOG  Rendering 1
 (NOBRIDGE) LOG  Rendering 2
 (NOBRIDGE) LOG  Recycled 0
 (NOBRIDGE) LOG  Recycled 1
 (NOBRIDGE) LOG  Recycled 2
 (NOBRIDGE) LOG  Rendering 3
 (NOBRIDGE) LOG  Recycled 3
 (NOBRIDGE) LOG  Recycled 4
 (NOBRIDGE) LOG  Rendering 4
 (NOBRIDGE) LOG  Rendering 4

I don't really understand mechanics of those hooks, and probably not be able to fix this issue alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant