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

[FlatList] render same dataRow too much every time #14528

Closed
ipenpen opened this issue Jun 15, 2017 · 33 comments
Closed

[FlatList] render same dataRow too much every time #14528

ipenpen opened this issue Jun 15, 2017 · 33 comments
Labels
Bug Component: FlatList Resolution: Locked This issue was locked by the bot.

Comments

@ipenpen
Copy link

ipenpen commented Jun 15, 2017

Dev - Environment

  • React Native version: 0.45
  • Platform: iOS
  • Development Operating System: macOS
  • Build tools: Xcode

Sample Code

class App extends Component {
  render() {
    return(
      <FlatList
        data={[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]}
        renderItem={({index})=>{
          console.log('renderItem', index);
            return <View></View>
        }}
      />
    );
  }
}

Problems

  • if data.length <= 10, it is ok, but
  • if data.length is bigger than 10, with each item in data renderItem() is called more than 1 time
  • the number of calling renderItem() of each data is near: (1 + (data.length - 10) / 10)
  • expected he number of calling renderItem() of each data is 1, not (1 + (data.length - 10) / 10)
  • time for rendering is too long and it lock others action like click, etc...

Sample Code's console log

renderItem 0
renderItem 1
renderItem 2
renderItem 3
renderItem 4
renderItem 5
renderItem 6
renderItem 7
renderItem 8
renderItem 9
renderItem 0

// from here render again
renderItem 1
renderItem 2
renderItem 3
renderItem 4
renderItem 5
renderItem 6
renderItem 7
renderItem 8
renderItem 9
renderItem 10
renderItem 11
renderItem 12
renderItem 13
renderItem 14
renderItem 15
renderItem 16
renderItem 17
renderItem 18
renderItem 19

// and render again
renderItem 0
renderItem 1
renderItem 2
renderItem 3
renderItem 4
renderItem 5
renderItem 6
renderItem 7
renderItem 8
renderItem 9
renderItem 10
renderItem 11
renderItem 12
renderItem 13
renderItem 14
renderItem 15
renderItem 16
renderItem 17
renderItem 18
renderItem 19
renderItem 20
renderItem 21
renderItem 22
@ipenpen ipenpen changed the title FlatList render same dataRow too much every time [BUG]FlatList render same dataRow too much every time Jun 15, 2017
@hramos hramos changed the title [BUG]FlatList render same dataRow too much every time [FlatList] render same dataRow too much every time Jun 15, 2017
@RodrigoCS
Copy link

+1, this is happening to me too with SectionList, items re-render multiple times.
This is what I get when I log, items and sections in its render method.

section Botanas
item 0
item 1
item 2
item 3
item 4
item 5
item 6
section Bebidas
item 0
section Botanas
item 0
item 1
item 2
item 3
item 4
item 5
item 6
section Bebidas
item 0
item 1
section Botanas
item 0
item 1
item 2
item 3
item 4
item 5
item 6
section Bebidas
item 0
item 1
item 2
item 3
item 4
item 5
item 6
item 7
item 8

This happens on first render and also on scrolling

@SteffenHummel
Copy link

same problem on Android

Dev - Environment

React Native version: 0.45.1
Platform: Android
Development Operating System: Linux Mint

@Jakevin
Copy link

Jakevin commented Jul 3, 2017

the same

React Native version: 0.45.1
Platform: Android & iOS
Development Operating System: mac 10.12.5

@fabfre
Copy link

fabfre commented Jul 3, 2017

we're experiencing the same problem with FlatList

React Native version: 0.44.2
Platform: iOS
Development OS: Mac 10.12

@oea-san
Copy link

oea-san commented Jul 12, 2017

Happening here too, is there any insights or progress into the matter?

React Native version: 0.44.0
Platform: iOS
Development OS: Mac 10.12.5

@markusekblad
Copy link

Happening for us too, with around 300 items my array I get several thousand calls to renderItem even with
initialNumToRender={10}
Same issue if I switch to a SectionList as well.

React Native version: 0.46.4
Platform: iOS and Android
Development OS: Mac 10.12.5

@markusekblad
Copy link

Upgrading to React Native 0.47.1 seems to have fixed it for me, it still seems to call renderItem quite a lot but there's a huge difference in performance now.

@artshin
Copy link

artshin commented Aug 10, 2017

Same thing for me. renderItem gets called for items that are clearly outside of the renderable area, setting initialNumToRender doesn't help reduce the number of render calls in any way.
FlatList essentially became a ScrollView, but worse.

React Native version: 0.47.1
Platform: iOS
Development OS: Mac 10.12.15

@artshin
Copy link

artshin commented Aug 10, 2017

After some testing and debugging I managed to get this fixed by explicitly setting windowSize property to a fixed reasonable value.

@cbjs
Copy link

cbjs commented Aug 16, 2017

same.

@koloritcm
Copy link

The same problem for me. The fundamental bug in this is that it is re-rendering everything for each extra 10 items. windowSize just reduces front loading and therefor just limit the symptoms a bit at the expense of user experience.

No official confirmation of this bug yet?

React Native version: 0.48.1
Platform: iOS
Development OS: Mac 10.12.6

@stale
Copy link

stale bot commented Nov 4, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 4, 2017
@stale stale bot closed this as completed Nov 11, 2017
@lasuax
Copy link

lasuax commented Nov 27, 2017

It doesn't seem to be fixed yet. Can we open it?

@joaovpmamede
Copy link

@lasuax did you try with the latest RN version?

@paulpopiel
Copy link

paulpopiel commented Dec 19, 2017

Experiencing the exact same issue with SectionList in "react-native": "0.50.3",

Can also replicate with a simple sample project in "react-native": "0.51.0"

@cbarlow1993
Copy link

Experiencing the exact same using "react-native": "0.45.1".

@m4r00p
Copy link

m4r00p commented Jan 16, 2018

Same with 0.51 ;/

@kelset
Copy link
Contributor

kelset commented Jan 19, 2018

This is happening to me too, I'll try to bring it up to core.

Even when using

        initialNumToRender={5}
        maxToRenderPerBatch={4}
        updateCellsBatchingPeriod={50}
        windowSize={5}
        onEndReachedThreshold={5}

Options in my SectionList, renderItem gets called xTimes too many.

Currently testing on an Android device on 7.x, rn 0.50.4. We'll upgrade (pro) today to 52, I'll let you know if it gets better with the newer version.

(possibly related: #14348)

@hramos hramos reopened this Jan 19, 2018
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 19, 2018
@mCodex
Copy link

mCodex commented Feb 5, 2018

I'm experiencing this issue too, even in RN 0.52.2. Has anyone found a solution?

@ishigamii
Copy link

Same issue any solution for this ?

@brentvatne
Copy link
Collaborator

https://facebook.github.io/react-native/docs/flatlist.html

use PureComponent for your list items as the docs suggest

@hoangtrinh96
Copy link

srsly still haven't had a solution for this ?

@mikaelrosquist
Copy link

mikaelrosquist commented Apr 4, 2018

Experiencing the same issue with RN 0.54.2.
@brentvatne Using PureComponent does not solve the issue.

@dougsleite
Copy link

Is there any alternative/recommendation while this is not fixed?

@VitaliiK91
Copy link

Had same issue. I had FlatList wrapped in a ScrollView, removing ScrollView wrapper fixed the problem

@tonywump
Copy link

tonywump commented Apr 8, 2018

Same issue here.
"react": "^16.3.1",
"react-native": "0.54.1"

@hoangtrinh96
Copy link

Hey everyone, I got this issue fixed, I don't know why PureComponent does not fix this, but you just need to implement the shouldComponentUpdated method in your item component, try to check whether nextProps is still the same with the oldProps, then return false.

@mtx62
Copy link

mtx62 commented Apr 9, 2018

Same issue here.
"react": "^16.3.0-alpha.1",
"react-native": "^0.54.2",

@unmec
Copy link

unmec commented Apr 11, 2018

"react-native": "^0.52.2"
Same here, will try @hoangtrinh96 suggestion

@alainib
Copy link

alainib commented Apr 27, 2018

same with "react-native": "^0.55.2

any solution ?

@johnckendall
Copy link

Confirming this behavior in:
"react": "16.3.1",
"react-native": "0.55.3",

@kelset
Copy link
Contributor

kelset commented May 9, 2018

@losheredos let me be extremely clear here: that language is NOT tolerated here. I'm going to remove that comment & report you.

@facebook facebook deleted a comment from losheredos May 9, 2018
@facebook facebook locked as too heated and limited conversation to collaborators May 9, 2018
@facebook facebook deleted a comment from react-native-bot May 15, 2018
@facebook facebook deleted a comment from react-native-bot May 16, 2018
@facebook facebook deleted a comment from react-native-bot May 16, 2018
@hramos hramos removed the Bug Report label Feb 6, 2019
@ferrannp
Copy link
Contributor

Hello there 👋 this issue has been reported for an old version of React Native. Ideally we'd like everyone to be using 0.59 (see the awesome changes it brought) but we know updating can be a pain. We are going to close this issue because it's from a version before 0.57, which is really old.

But please, if it's actually still an issue with 0.59 please comment below and we can reopen it 😊

@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: FlatList Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests