Skip to content

🐛 Bug Report: Infinite Render Loop in FlashList v2 (setRenderId) #1773

Closed

Description

@Prajwaltechversant

We encountered a crash in FlashList v2 (flashlist@2.x.x) that causes a maximum update depth exceeded error. This issue does not occur in FlashList v1, making it a regression.

error : "Render Error
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate."

✅ Expected Behavior

FlashList should avoid triggering an infinite re-render loop when modifying layout or handling orientation changes.

Image

🔄 Actual Behavior
FlashList v2 causes setRenderId to continuously update, triggering an infinite loop and crashing the app.

🔙 Regression
✅ Yes — this issue does not happen in v1, so it is a regression in v2.

✍️ Additional Notes
We tried using extraData and forcing keys to re-render, but it did not prevent the crash.

This may be linked to how modifyChildrenLayout() internally triggers updates.

Activity

  1. added
    bug
    on Jul 14, 2025
  2. Prajwaltechversant commented on Jul 14, 2025

    @Prajwaltechversant
    Author

    @naqvitalha i got this crash both in debug and release. in v1 works fine without this crash

  3. Prajwaltechversant commented on Jul 14, 2025

    @Prajwaltechversant
    Author

    @naqvitalha i also tried this in flatlist, works fine there

  4. Prajwaltechversant commented on Jul 14, 2025

    @Prajwaltechversant
    Author

    @naqvitalha data={listData.filter(f => !!f)} or data={listData.slice()} fixes the crash ,data={[...listData])} fixes the crash , does this make any sense

  5. tsdevshop commented on Jul 14, 2025

    @tsdevshop
    Contributor

    Issue appears to be coming from this line, which is setting state inside a useLayoutEffect with no deps. As a result, the state is set, component re-renders, which fires the useLayoutEffect, which sets the state, which re-renders the component... etc.

    Perhaps we need a way to short-circuit this if the layout measurements aren't stable?

  6. naqvitalha commented on Jul 14, 2025

    @naqvitalha
    Collaborator

    Some more details or a repro will be helpful. This issue only happens when there's something wrong with list setup like duplicate keys in keyExtractor or having a list inside a ScrollView causing all items to render at one. If it's neither then I can look into it.

  7. Prajwaltechversant commented on Jul 15, 2025

    @Prajwaltechversant
    Author

    Hi @naqvitalha ,
    I've verified that the keyExtractor is not generating any duplicate keys. The crash still occurs even when renderItem={null} or when the render component is not being used.

  8. AjayFrancisTechversant commented on Jul 15, 2025

    @AjayFrancisTechversant

    @naqvitalha , any updates on this?

  9. naqvitalha commented on Jul 15, 2025

    @naqvitalha
    Collaborator

    I'd appreciate a repro for this or some more details. A video might help too. We do render in a loop but it's always supposed to end unless your items keep changing their size or you're rendering too many to begin with (hundreds).
    There can be some bug but since I don't have a repro, I can't do much. We also changed how we mount in alpha.21 so if this is happening on mount, you can try the new version.

  10. Prajwaltechversant commented on Jul 16, 2025

    @Prajwaltechversant
    Author

    HI @naqvitalha ,
    I'll check that in the alpha version. Do you have an estimated timeline for the RC (release candidate) version?

  11. Prajwaltechversant commented on Jul 16, 2025

    @Prajwaltechversant
    Author

    Hi @naqvitalha , works fine in alpha release

  12. Gothamoo7 commented on Jul 16, 2025

    @Gothamoo7

    @Prajwaltechversant @naqvitalha I'm getting the same issue in alpha.21 as well, if the list has more than 50 items.
    Any workaround?

  13. Prajwaltechversant commented on Jul 16, 2025

    @Prajwaltechversant
    Author

    HI @Gothamoo7 , for me , the rendering issues is fixed in alpha 21.

  14. Prajwaltechversant commented on Jul 16, 2025

    @Prajwaltechversant
    Author

    @Gothamoo7 data={listData.filter(f => !!f)} or data={listData.slice()} fixes the crash ,data={[...listData])} fixes the crash , try this

  15. naqvitalha commented on Jul 16, 2025

    @naqvitalha
    Collaborator

    @Gothamoo7 Can you provide a repro (on expo snack) ? 50 items shouldn't cause this.

  16. 11 remaining items

  17. Freddy03h commented on Aug 29, 2025

    @Freddy03h

    Hi, I experienced same issue while upgrading to v2, with horizontal list nested in vertical list.

    I reproduced the issue here : https://snack.expo.dev/@freddy03h/flashlist-horizontal-bug-repro
    I observed that if you provide a ListHeaderComponent in the nested horizontal list, there is no Maximum update depth exceeded


    In my app (with more complexe components, that works with v1), there is no Maximum update depth exceeded if i provide a ListHeaderComponent and/or ListFooterComponent in the horizontal nested list, but I experienced an other issue (that I can't repro in a snack) :

    -[UIView(ComponentViewProtocol) updateLayoutMetrics:oldLayoutMetrics:]: Received invalid layout metrics ({{1.0036404577283287e+38, 0}, {inf, 3.4028234663852886e+38}}) for a view (<RCTViewComponentView: 0x11f28ba20; frame = (-8.98847e+307 -8.98847e+307; 1.79769e+308 1.79769e+308); transform3D = [nan, nan, 0, 0; nan, nan, 0, 0; nan, nan, 1, 0; nan, nan, nan, nan]; tag = 6042; backgroundColor = UIExtendedSRGBColorSpace 0 0 0 1; layer = <CALayer: 0x6000004b5e20>>).
    

    I don't know if it can help 😅

    react-native@0.80.2

  18. VladosK0k0s commented on Sep 3, 2025

    @VladosK0k0s

    Fixed this by wrapping array with useMemo

    data={[...pastSessions, ...futureSessions, 'offset' ]} =>

    const items = useMemo(
      () => [...pastSessions, ...futureSessions, 'offset'],
      [pastSessions, futureSessions],
    );
    data={items}
    
    
  19. Freddy03h commented on Sep 4, 2025

    @Freddy03h

    In my example, data is created outside func cmp, so there is no render because of data changes.

  20. Prajwaltechversant commented on Sep 8, 2025

    @Prajwaltechversant
    Author

    Hi @naqvitalha

    I’m still running into the same crash even when using:
    flash-list@2.0.3

    The behavior looks identical to the original issue — FlashList enters a render loop and React throws Maximum update depth exceeded.

    Steps I’ve tried to rule out usage issues:
    Verified data and renderItem are memoized/stable
    Environment:
    React Native:0.80.2

    FlashList: 2.0.3, 2.0.2, 2.0.0

    Platform: Both

    Image Image
  21. naqvitalha commented on Sep 9, 2025

    @naqvitalha
    Collaborator

    @Freddy03h I'm looking into the repro you provided. If anyone else has another one, please share.

  22. self-assigned this
    on Sep 9, 2025
  23. naqvitalha commented on Sep 10, 2025

    @naqvitalha
    Collaborator

    @Freddy03h I've put up a PR with a fix: #1899. You check test the fix in v2.0.4-alpha.1

  24. Freddy03h commented on Sep 11, 2025

    @Freddy03h

    @naqvitalha Thank you! I tested it and still experience the Maximum update depth exceeded if I remove ListHeaderComponent and ListFooterComponent from the horizontalList.

    I observed something else : If I set a style={{width, height}} to the horizontalList (based on my previous estimatedListSize), even without ListHeaderComponent and ListFooterComponent, there is no Maximum update depth exceeded.

    But in all cases where there is no Maximum update depth exceeded, I still experience an [UIView(ComponentViewProtocol) updateLayoutMetrics:oldLayoutMetrics:]: Received invalid layout metrics with graphic glitch rendering. (but maybe that's an other issue)

  25. naqvitalha commented on Sep 11, 2025

    @naqvitalha
    Collaborator

    @Freddy03h It makes sense why adding header or size fixes it. We render lazily and not having size increases the number of setState calls we need to make. With header being there, we have a size to work with.
    My fix significantly reduces the number of calls needed. It fixed the sample you provided: https://snack.expo.dev/@naqvitalha/flashlist-horizontal-bug-repro

    Do you have a huge number of items rendering on mount (vertical list children + horizontal list children)? Can you provide another repro and a screen shot of what you're trying to render?

  26. Freddy03h commented on Sep 18, 2025

    @Freddy03h

    Hi! Sorry for the delay!

    I rework my component for the horizontal list (it was flexible because it is supposed to work on a grid, but with the removed fixed container size, it was trapped in a render loop and caused glitches).

    So for me, it's ok with this issue 👍

    Maybe other people here @Prajwaltechversant @manastelavane @varungandhi121 @VladosK0k0s @Gothamoo7 can test and confirm the fix on the v2.0.4-alpha.1 ?

  27. Prajwaltechversant commented on Sep 19, 2025

    @Prajwaltechversant
    Author

    Hi @Freddy03h @naqvitalha
    My issue with the infinite render loop error and crash while opening the FlashList component was fixed in v2.0.4-alpha.1. However, I am now facing a similar issue when scrolling the list.

  28. naqvitalha commented on Sep 25, 2025

    @naqvitalha
    Collaborator

    @Prajwaltechversant I'd really appreciate if you can create a repro on expo snack. I will take a look. We've shipped v2.1.0 with all the fixes made so far.

  29. weizhe412 commented on Sep 26, 2025

    @weizhe412

    Also found this issue on my project and 2.1.0 still did not work
    I added a fixed width on style and solved it (worked at least on 2.0.2)

  30. naqvitalha commented on Oct 14, 2025

    @naqvitalha
    Collaborator

    Hey folks, I'll be closing this issue since it's not actionable. If anyone still has a problem please open a new one with a repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugv2.0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions