FlatList renderItem is called multiple times

瘦欲@ 提交于 2019-11-27 09:51:10

Normal re renders are normal in RN. That is just RN updating the react tree and updating views. If you dont have a performance issue then you can ignore this.

Otherwise, please explain the problem because the console log is fine. Render item executes for EACH item in the data array you pass to FlatList. That is the render function for each item, not the render for the whole list.

If this is not clear enough, and it is easier for you, feel free to add here a comment in Spanish and then we can update the answer (Only saying this since by your user, you seam spanish speaker as I am)

https://snack.expo.io/B1KoX-EUN - For optimization and prevent re-render you can call shouldComponentUpdate(nextProps, nextState) to diff this.state or this.props and return true/false - https://reactjs.org/docs/react-component.html#shouldcomponentupdate docs say this callback should be used only for optimization which is what we're doing here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!