android: Scrapped or attached views may not be recycled
Environment
"@react-navigation/material-top-tabs": "^6.6.14", "@react-navigation/native": "^6.1.18", "@react-navigation/native-stack": "^6.11.0", "react": "18.3.1", "react-native": "0.75.2", "react-native-pager-view": "^6.3.4", "react-native-safe-area-context": "^4.10.9", "react-native-screens": "^3.34.0", "react-native-tab-view": "^3.5.2"
Description
I have a tab navigator in a post login stack, one of the tabs visibility is based on the value of a state variable. When i do logout, first i'm setting the value of the state variable to false, then switching the stack to pre login stack. at this time app is getting crashed.
Getting logs in Android studio like below java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true androidx.viewpager2.widget.ViewPager2$RecyclerViewImpl{7d03f4b VFED..... .......D 0,0-1080,1736 #2}, adapter:com.reactnativepagerview.ViewPagerAdapter@5f5fd28, layout:androidx.viewpager2.widget.ViewPager2$LinearLayoutManagerImpl@1cf2a41, context:com.facebook.react.uimanager.ThemedReactContext@c1e63c
Reproducible Demo
https://github.com/rifad4u/pagerviewcrash.git
+ 1
Hi @rifad4u
Just a quick reminder to please avoid pinging other contributors unnecessarily. Let's ensure we're not disturbing others unless it's critical to the discussion. Thanks for your understanding and cooperation! PRs and other investigations are welcome 🙏
Best regards, Piotr Trocki
@kamill90, please check this issue in your free time 🙏
The same problem
Any update on this issue? Im facing this issue on react native 0.75.4 with "react-native-pager-view": "^6.4.1",
- 1
Looking into this
enabled new arch. same error
Thank you @MrRefactor
Similar issue: https://github.com/callstack/react-native-pager-view/issues/891#issuecomment-2447236943
enabled new arch. same error
When new arch type is disabled error is resolved.
Any update? I just saw this package and I installed it in my RN app that uses version 0.76, after I implemented the PagerView whenever I try to use anything related to navigation the app crashes.
Getting the same issue in RN 0.73.9, do we have any update?
As I messaged previously, looking into that issue. Feel free to contribute and open PR.
I got this because I was following the example with reanimated library, I don't have this error after I get rid of reanimated from react-native-pager-view.
Getting the same issue in RN 0.76.1 when newArchEnabled=true, do we have any update?
I am facing same issue on react-native 0.76.1 and react-native-pagerview - 6.5.0
+1
Getting the same issue in RN 0.76.1 when newArchEnabled=true, do we have any update?
I am even getting this issue when newArchEnabled=false
+1 getting the same issue
+1
Same issue here +1
+1 on new arch with expo 52
+1, RN 0.76.2 with newArchEnabled
It's fixed now in the latest release, thank you @MrRefactor!!!
Closing as fixed
@MrRefactor this issue is back in 6.6.0 on Fabric, probably due to #929
https://github.com/callstack/react-native-pager-view/releases/tag/v6.6.1 @radko93
This error / crash still occurs when you do:
pageMargin={24}