Removing last page when it's active causes a crash in iOS on RN 0.64
See original GitHub issueEnvironment
- react-native: 0.63.4
- react-native-pager-view: 5.4.7
Description
If we remove the last child of the PagerView, when it’s active, iOS crashes with:
Exception thrown while executing UI block: *** -[__NSArrayM objectAtIndexedSubscript:]: index 4 beyond bounds [0 .. 3]
__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke
RCTUIManager.m:1199
__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.496
__RCTExecuteOnMainQueue_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start
Reproducible Demo
This is a minimal case that we can verify this crash happening. A simple app to navigate to the 5th (last) page and press the text to remove it. iOS should crash.
import React, {useState} from 'react';
import {Text, View} from 'react-native';
import PagerView from 'react-native-pager-view';
const App = () => {
const [pages, setPages] = useState(5);
return (
<PagerView style={{flex: 1}} initialPage={0}>
{new Array(pages).fill().map((_, i) => (
<View
key={i}
style={{width: '100%', height: '100%', justifyContent: 'center', alignItems: 'center'}}>
{i !== pages - 1 ? (
<Text>Please navigate to next page -></Text>
) : (
<Text
onPress={() => {
setPages(pages - 1);
}}>
Press me to remove this page
</Text>
)}
</View>
))}
</PagerView>
);
};
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
App crashes after deleting list it… | Apple Developer Forums
The crash occurs sometime between the last executable line of code in a delete confirmation alert which reloads the list of items in...
Read more >Using Hermes - React Native
You can still disable Hermes using the command described in this page. You can read more about the technical implementation on this page....
Read more >React Native - Sentry Documentation
On this page, we get you up and running with Sentry's SDK, so that it will automatically report errors and exceptions in your...
Read more >Using Hermes in React Native - LogRocket Blog
We'll walk you through the necessary steps to get your React Native application up and running with Hermes as the JavaScript engine. Here's...
Read more >Deleting last row of a section causes crash - Stack Overflow
So I have a table view of custom cells. Whenever I try to delete the last row in a given section, the app...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/callstack/react-native-pager-view/releases/tag/v5.4.9
@troZee Tried the latest release as well, the fix is not solving the iOS crash issue.