undefined is not an object options.routeGetIdList[action.payload.name]

Viewed 1162

When navigating to another page it gives an undefined error. Normally no changes have been made.I deleted node_modules and reinstalled. I reset the codes. I deleted the project and restarted. but there was no solution.

TypeError: undefined is not an object (evaluating 'options.routeGetIdList[action.payload.name]')

import { Button, View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

function HomeScreen({ navigation }) {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screen</Text>
      <Button
        title="Go to Details"
        onPress={() => navigation.navigate('Home')}
      />
    </View>
  );
}

function DetailsScreen() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Details Screen</Text>
    </View>
  );
}

const Stack = createStackNavigator();

function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Home">
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Details" component={DetailsScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
export default App;
    "@react-native-async-storage/async-storage": "^1.13.2",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/datetimepicker": "^3.0.9",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-firebase/admob": "^7.6.12",
    "@react-native-firebase/analytics": "^8.0.1",
    "@react-native-firebase/app": "^9.0.0",
    "@react-native-firebase/firestore": "^7.10.3",
    "@react-navigation/native": "^5.9.2",
    "@react-navigation/stack": "^5.12.6",
    "emoji-regex": "^9.2.1",
    "firebase": "^8.0.1",
    "grapheme-splitter": "^1.0.4",
    "react": "16.13.1",
    "react-native": "0.63.3",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-onesignal": "^3.9.2",
    "react-native-raw-bottom-sheet": "^2.2.0",
    "react-native-reanimated": "^1.13.2",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.17.1",
    "react-native-snapchat-login": "^1.1.1",
    "react-native-vector-icons": "^7.1.0"
  },```
2 Answers

Go to node_modules\@react-navigation\routers\src\StackRouter.tsx

And do the change as below in line 261 and 368

options.routeGetIdList to options.routeNames

This fixed my issue

The same error was occurring to me when navigating to another screen, to resolve it I just updated the following dependencies to the latest version:

@react-navigation/native

@react-navigation/stack

Then I cleared the cache and ran the project:

cd android && gradlew clean && cd .. && react-native run-android
Related