ReactFix
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • React
  • React Native
  • Programming
  • Object Oriented Programming

Wednesday, December 14, 2022

[FIXED] How to prevent tabs from updating / re-rendering when they are not focused?

 December 14, 2022     react-native, react-navigation   

Issue

I'm using material top tabs. Problem is, when a state changes in one tab, all other tabs that use the same state render again which slows the app a little. How do I prevent tabs from getting updated unless they are focused / seen ?


Solution

In your components, you can get state property and detect is it in focus or not. And if it is not in focus you can prevent rerendering or place your own logic. An example is here: https://reactnavigation.org/docs/material-top-tab-navigator#tabbar



Answered By - Kirill Novikov
Answer Checked By - - Mary Flores (ReactFix Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post Home

Featured Post

Is Learning React Difficult?

React is difficult to learn, no ifs and buts. React isn't inherently difficult to learn. It's a framework that's different from ...

Total Pageviews

Copyright © ReactFix