Fix memory leaks when PagerView is unmounted #1040
Bugbot Review
Bugbot Analysis Progress (2m 30s elapsed)
✅ Gathered PR context (2s)
✅ Analyzed code changes (1s)
✅ Completed bug detection — 4 potential bugs found (2m 17s)
✅ Validation and filtering completed (0s)
✅ Posted analysis results — 4 bugs reported (10s)
✅ Analysis completed successfully (0s)
Final Result: Bugbot completed review and found 4 potential issues
Request ID: serverGenReqId_4497eb08-89f4-469d-a316-5065c4b7ae03
Details
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bug: Nil object access during component recycling.
After prepareForRecycle sets scrollView = nil on line 158, updateProps accesses scrollView.scrollEnabled without a nil check. If the component is recycled and updateProps is called before willMoveToSuperview reinitializes the view, this causes a crash or undefined behavior when accessing properties on a nil object.
ios/RNCPagerViewComponentView.mm#L204-L206
react-native-pager-view/ios/RNCPagerViewComponentView.mm
Lines 204 to 206 in 71650e3
Bug: Imperative Commands Crash on Nil State Access
The setScrollEnabledImperatively method accesses scrollView without checking if it's nil. After prepareForRecycle sets scrollView = nil on line 158, calling this imperative command from JavaScript will crash or produce undefined behavior. Since this is an imperative API callable at any time, it needs a nil check.
ios/RNCPagerViewComponentView.mm#L425-L428
react-native-pager-view/ios/RNCPagerViewComponentView.mm
Lines 425 to 428 in 71650e3