react-native-tab-view icon indicating copy to clipboard operation
react-native-tab-view copied to clipboard

Too many initial renders for the FirstRoute

Open mydesweb opened this issue 3 years ago • 10 comments

Current behavior

The FirstRoute is rendered 3 or 5 times on initial mount. Why so many?

Just add a console.log in FirstRoute render method. Possible this issue exists only in the latest version release.

Expected behavior

Only one render should be enough.

Reproduction

https://snack.expo.dev/@mydesweb/react-native-tab-view-quick-start

Platform

  • [ ] Android
  • [X] iOS
  • [ ] Web
  • [ ] Windows
  • [ ] MacOS

Environment

package version
react-native-tab-view 3.1.1
react-native-pager-view 5.4.9
react-native 0.66.3

mydesweb avatar Nov 30 '21 18:11 mydesweb

same here.

brunofariasd avatar Dec 07 '21 11:12 brunofariasd

Can React.memo solve this problem?

likeSo avatar Dec 24 '21 05:12 likeSo

@likeSo no, it's about something else.

mydesweb avatar Dec 24 '21 09:12 mydesweb

@mydesweb @likeSo @brunofariasd I believe it is because of the warning in the documentation:

IMPORTANT: Do not pass inline functions to SceneMap

=> on every state update you do, it will re-render the tabview entirely

I also tried to use the customized renderScene they suggest when you want to pass some props to it, but then the event "onIndexChange" is no longer caught. And switching from a tab to another completely remove / rebuild the previous tab on switching... terrible performance.

Did you guys manage to find a solution?

pierroo avatar Dec 31 '21 12:12 pierroo

Having this for Android too

AlaaEdAouimeur avatar Feb 16 '22 15:02 AlaaEdAouimeur

any updates ?

MedRaid avatar Apr 26 '22 13:04 MedRaid

@pierroo we DO NOT use inline functions, I already provided an example and you can check the source code

mydesweb avatar May 04 '22 11:05 mydesweb

@mydesweb the base example is rerendering, not only in the initial mount but also on changing tabs all tab views rerender but I noticed something on the initial render only the first and second route is rerendered twice reproduced here https://github.com/satya164/react-native-tab-view/issues/1341

Mohamed-kassim avatar May 04 '22 19:05 Mohamed-kassim

Same issue here ( all views are rendered when switching tabs ):

Windows 10 Android "react": "17.0.2", "react-native": "0.68.1", "react-native-tab-view": "^3.1.1", "react-native-pager-view": "^5.4.15",

BarmakHA avatar May 16 '22 06:05 BarmakHA

same here. any updates?

belaziv avatar Jun 20 '22 09:06 belaziv