I am creating a react native app. I don’t know what I did to cause this issue, but now it appears even if I comment out my entire app except for a single . Sometimes it randomly doesn’t occur, but I have no way of eliminating it completely.
NSRangeException: * -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array
The only Array in my app is a pre-set array that is always full, so I don’t think that can cause this issue. But this flatlist is the only place it’s used.
import { FlatList, View, Text, TouchableHighlight } from "react-native";
import { useContext } from "react";
import Swipeable from "react-native-gesture-handler/Swipeable";
import { arrData } from "../../data";
import { PlayingContext } from "../../app/_layout";
import ListItem from "../ListItem/index";
import SwipeButtons from "../SwipeButtons";
import MantraListStyles from "./MantraList.styles";
const { container, list } = MantraListStyles;
const MantraList = () => {
const changeContext = useContext(PlayingContext).setPlaying;
const handlePress = (newPlaying) => {
changeContext(newPlaying);
};
return (
<View style={container}>
<FlatList
data={arrData}
keyExtractor={(item) => item?.id}
showsVerticalScrollIndicator={false}
renderItem={({ item }) => (
<Swipeable renderRightActions={() => <SwipeButtons />}>
<TouchableHighlight
activeOpacity={0.85}
underlayColor="darkgrey"
onPress={() => handlePress(item)}
>
<ListItem fileData={item} />
</TouchableHighlight>
</Swipeable>
)}
style={list}
/>
</View>
);
};
export default MantraList;
Again, I have completely deleted this component in some cases, and the error continued to occur. I have commented out everything, and it continued to occur.
2
Answers
I’m having the same issue, I was able to get rid of the error page by changing versions for react-native-gesture-handler by following this post https://stackoverflow.com/a/75958440
Try cleaning Xcode’s derived data, clean the xcode project and run npm start –reset-cache in root folder of your react-native project