meliorence / meliorence/react-native-snap-carousel

renderItem per item is called 3 times on 1 Carousel render

Open
#801 1 comment 12 reactions 0 assignees View on GitHub

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?
Have you made sure that it wasn't a React Native bug?

Not react native bug.

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Not specific to any platform.

Is the bug reproductible in a production environment (not a debug one)?

Yes.

Environment

Environment:
React: 16.13.1
React native: 0.63.2
react-native-snap-carousel: 3.9.1

Target Platform:
Android (latest)
iOS (14.3)

Expected Behavior

On 1 Carousel render I expect each item to render once for improved performance.

Actual Behavior
  • Carousel rendered once.
  • Each initial item rendered once.
  • interpolators in state changed.
  • Each initial item rerendered 2nd time.
  • hideCarousel in state changed.
  • Each initial item rerendered 3rd time.

Comparing to regular Flatlist which caused CPU to go to 110%, with Carousel because of 3 rerenders it went to 270%.
Performance wise it is very problematic.

Reproducible Demo

https://snack.expo.io/@bolts/courageous-coffee

Steps to Reproduce
  1. On initial 1 render each render item console log is called 3 times

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Snack reproduction and trace the Carousel's initial render along with the interpolators and hideCarousel state changes described in the report. Confirm the three render calls, then verify that each initial item renders once without regressing the reported Android and iOS behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
frontend, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.