react-native-tab-view
react-native-tab-view copied to clipboard
Too many initial renders for the FirstRoute
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 |
same here.
Can React.memo
solve this problem?
@likeSo no, it's about something else.
@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?
Having this for Android too
any updates ?
@pierroo we DO NOT use inline functions, I already provided an example and you can check the source code
@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
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",
same here. any updates?