2

Reloading the application on Android emulator (google pixel 5), I am receiving the following error:

screenshot of android emulator with error

TypeError: undefined is not an object (evaluating 'config.props')

This error is located at:
    in NativeStackNavigator (created by wrappedComponent)
    in wrappedComponent (created by AppNavigator)
    in EnsureSingleNavigator
    in BaseNavigationContainer
    in ThemeProvider
    in NavigationContainerInner (created by AppNavigator)
    in AppNavigator (created by App)
    in ErrorBoundary (created by App)
    in RNCSafeAreaProvider (created by SafeAreaProvider)
    in SafeAreaProvider (created by App)
    in ThemeProvider (created by App)
    in QueryClientProvider (created by App)
    in App (created by ExpoRoot)
    in ExpoRoot
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
at node_modules/@sentry/utils/dist/instrument.js:111:20 in <anonymous>
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/ReactFiberErrorDialog.js:43:2 in showErrorDialog

I've tried to update to the latest compatible version of react navigation.

  • expo install @react-navigation/native-stack
  • expo install @react-navigation/native
  • expo install @react-navigation/stack

...and expo doctor didn't find any issues with the project.

my setup:

  • expo: v44
  • @react-navigation/native: ^6.0.10
  • @react-navigation/native-stack: ^6.0.2
  • @react-navigation/stack: ~6.0.1
Steven Dew
  • 31
  • 5
  • What do you mean by "reloading", do you have the error immediately when you launch the emulator ? Also, can you show the code related to screens and routes ? You may want to remove parts your code, until you find the part that error. – Ambroise Rabier May 27 '22 at 19:48

1 Answers1

1

Looking at the source code:

    const config = screens[route.name];
    const screen = config.props;

Either screens is not containing what you expect it to contain, or route.name is not what you expect.

// In case you are unfamiliar with JS

// screens[route.name]
let screens = {'hello': 33};
console.log(screens['hi']); // undefined

screens = {'hi': 33};
console.log(screens['hello']) // undefined

There is a lot of checks for screens here, so we may assume that screens is not empty.

If you are in production, you have a slightly different behavior for routes.

You are probably trying to access a route that doesn't exist.

Ambroise Rabier
  • 3,636
  • 3
  • 27
  • 38
  • Thanks Ambroise, your suggestion made us realize that the user was trying to navigate to a screen that they weren't authorized to see yet (waiting for a token when refreshing the app, not on initial load). This was causing our issues. – Steven Dew May 31 '22 at 13:51
  • 1
    @StevenDew Happy to know it helped ! You can mark this answer as accepted. Or you can make your own answer and share the detail of the fix, if you think that be helpful for others users facing the same issue, if you like to. – Ambroise Rabier May 31 '22 at 16:15