react-nativejsx

The problems be Cannot read property 'key' of undefined in react native?


enter image description here

I'm getting the problem since yesterday, I didn't find any solution for it, please help me, Although I don't have a typo in the codeز

App.js

import React from "react";
import LogIn from "./components/LogIn";
import Sales from "./components/Sales";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";

const Stack = createStackNavigator();

function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen
          options={{
            headerTintColor: "#0b4079",
            headerShown: false,
            cardStyle: {
              backgroundColor: "#fff"
            }
          }}
          name="تسجيل الدخول"
          component={LogIn}
        />
        <Stack.Screen
          options={{
            headerShown: false
          }}
          name="المبيعات"
          component={Sales}
        />
      </Stack.Navigator>
    </NavigationContainer>
  );
}


Solution

  • Based on the image you attached, it seems the issue is in StackView.tsx, not App.js which is directly related to react-navigation in their source here.

    Can you provide more code snippets where the error is being thrown―further down the stack trace? The App.js isn't the problem here, because running that on its own seems to work fine on my end.