React-native-tab-view: On tapping on tabs transition is very slow but on swipe it is very smooth
Asked Answered
H

0

6

I am using react-native-tab-view for the tabs but when I am clicking on tabs transition is very slow. And on swipe it is smooth and fast. What I did to resolve it:- I make all sub component a PureComponent which is being rendered on index change. That means it will not re-render if content is not different from previous. And I crossed checked if components is being re-rendered or not and components are not re-rendering. But still it lagging or slow transition if click on tabs(not on swipe)

Havoc answered 4/2, 2020 at 9:47 Comment(9)
I am facing same problem, did you find any solution of this issue ?Odelet
Buddy.. u have to optimize your code. It should not be rendered again once it is rendered. I optimized my code then it is solved. Use PureComponent or shouldComponentUpdate in your componentsHavoc
yes. i did this and worked for me as wellOdelet
@ShankarMorwal I agree that you handled through PureComponents but why it was working fine when scrolling ? Any thoughts ?Donndonna
@Donndonna - Was you able to fix this issue?Crocus
Yeah, Actually you need to optimize the code. For each component use "extends PureComponents" or for functional component use "React.memo" that's how you can optimize it.Havoc
I haveadded but I can see any impact. In my page, I have about 9 tabs and each tab has data containing 8=9 items.Crocus
The only reason of its slowdown or lag is multiple rendering all the items in all 9 tabs. Try printing console.log() you will see whenever you change the tab all the items gets printed. To resolve this I think separate each and every component (tabs components). Use PureComponent in list items not in the whole tab.Havoc
this is happening to me when I use lazy: true props. has anyone resolved the issue ?Azure

© 2022 - 2024 — McMap. All rights reserved.