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)
Asked
Active
Viewed 2,261 times
6
-
I am facing same problem, did you find any solution of this issue ? – Shankar Morwal Feb 24 '20 at 11:41
-
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 components – Mani Kant Tiwari Feb 26 '20 at 10:15
-
yes. i did this and worked for me as well – Shankar Morwal Feb 28 '20 at 08:52
-
@ShankarMorwal I agree that you handled through PureComponents but why it was working fine when scrolling ? Any thoughts ? – ankitjaiswal Aug 27 '20 at 15:43
-
@ankitjaiswal - Was you able to fix this issue? – Anuj Raghuvanshi Jul 16 '21 at 10:45
-
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. – Mani Kant Tiwari Jul 16 '21 at 11:04
-
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. – Anuj Raghuvanshi Jul 16 '21 at 11:34
-
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. – Mani Kant Tiwari Jul 16 '21 at 11:39
-
this is happening to me when I use `lazy: true` props. has anyone resolved the issue ? – Bryan Lumbantobing May 08 '23 at 01:03