Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'props' of undefined #11113

Closed
3 of 14 tasks
beqramo opened this issue Dec 20, 2022 · 16 comments
Closed
3 of 14 tasks

TypeError: Cannot read property 'props' of undefined #11113

beqramo opened this issue Dec 20, 2022 · 16 comments

Comments

@beqramo
Copy link

beqramo commented Dec 20, 2022

Current behavior

In production from Sentry, I'm receiving error reporting from react-navigation.
According to report, it looks like it is only happening on IOS devices.

here is the most recent stack trace:

TypeError: Cannot read property 'props' of undefined
  at <global>(node_modules/@react-navigation/core/src/useDescriptors.tsx:160:26)
  at reduce(native)
  at <global>(node_modules/@react-navigation/core/src/useDescriptors.tsx:141:23)
  at <global>(node_modules/@react-navigation/core/src/useNavigationBuilder.tsx:667:37)
  at <global>(node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx:78:25)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:3360:22)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7227:34)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:6771:25)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:6764:54)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:6746:19)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:6454:34)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:2058:31)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7948:58)
  at <global>(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1010:30)

Expected behavior

props shouldn't be undefined in react-navigation

Reproduction

I'm not able to share repo publicly here, sorry

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/​bottom-tabs
  • @react-navigation/​drawer
  • @react-navigation/​material-bottom-tabs
  • @react-navigation/​material-top-tabs
  • @react-navigation/​stack
  • @react-navigation/​native-stack
  • react-native-tab-view
  • flipper-plugin-react-navigation

Environment

  • I've removed the packages that I don't use
package version
@react-navigation/native ~6.0.11
@react-navigation/bottom-tabs ^6.3.2
@react-navigation/stack ~6.2.2
@react-navigation/native-stack ^6.7.0
react-native-safe-area-context 4.3.1
react-native-screens 3.15.0
react-native-gesture-handler 2.5.0
react-native-reanimated 2.9.1
react-native 0.68.2
npm or yarn yarn
@beqramo beqramo added the bug label Dec 20, 2022
@github-actions
Copy link

Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a snack.expo.dev link, a www.typescriptlang.org/play link or link to a GitHub repo under your username).

Can you provide a minimal repro which demonstrates the issue? Please try to keep the repro as small as possible and make sure that we can run it without additional setup.

A repro will help us debug the issue. The issue will be closed automatically after a while if you don't provide a repro.

@github-actions
Copy link

Couldn't find version numbers for the following packages in the issue:

  • react-native-tab-view
  • flipper-plugin-react-navigation

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 6.0.11, latest: 6.1.1)
  • @react-navigation/bottom-tabs (found: 6.3.2, latest: 6.5.2)
  • @react-navigation/stack (found: 6.2.2, latest: 6.3.10)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@github-actions
Copy link

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.

@beqramo
Copy link
Author

beqramo commented Apr 4, 2023

I don't think it should be closed:
still receiving events on sentry.
I can event say the line where it is happening.
image

@github-actions
Copy link

github-actions bot commented Apr 4, 2023

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.

@rishabhmhjn
Copy link

rishabhmhjn commented Apr 7, 2023

I am facing a similar issue where we use initialState and then change the available routes underneath due to auth updates.

The routes defined in the initialState didn't exist in the following updated structure, so it throws the error.

It has more to do with handling the initialState change when routes change.

https://reactnavigation.org/docs/auth-flow/#removing-shared-screens-when-auth-state-changes

@kyoto21
Copy link

kyoto21 commented Jun 15, 2023

lately i got the problem to... it appear on ios or android sometimes... i fixed it by clean data and cache (android) and reinstall app (ios)

@focux
Copy link

focux commented Jul 18, 2023

@rishabhmhjn Ya, I think that's what causing the error, did you find any workaround?

@AlkanV
Copy link

AlkanV commented Jul 24, 2023

i have the same issue. any solution for it?

@rishabhmhjn
Copy link

rishabhmhjn commented Aug 27, 2023

@rishabhmhjn Ya, I think that's what causing the error, did you find any workaround?

@focux apologies, I believe we did manage a workaround and released our app, but I cannot recall what we did on top of my mind now. I will update you as soon as I remember something related to it.

@betocolon23
Copy link

bug

Hi everyone, im having this issue only on ios (expo). If I run the simulator on ios it works but when I read the QR code in expo to test it in my phone it throws the error. Any thoughts?

My expo SDK version is 49.0.0

@beqramo
Copy link
Author

beqramo commented Oct 25, 2023

Hi, in my case problem was initial navigation state that I was passing during the navigationContainer initialisation.
Have in mind that navigation needs to be ready before do any navigation too.

Thanks

@Iuriy-Budnikov
Copy link

I'm getting this error when I open a deep link and app is off
image

@anujkumar09062001
Copy link

Say we've two routes named Login and Welcome make sure the initialRouteName prop given to the root navigator matches names of the screens i.e Login and Welcome

type RouteNames = "Login"|"Welcome"

 <Stack.Navigator
        // this should either be Login or Welcome in our case
        initialRouteName={"Login"}
      >
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Welcome" component={WelcomeScreen} />
 </Stack.Navigator>

Wrong route name was leading to ❌ the aforementioned errors as there's no screen corresponding to SignUp name

<Stack.Navigator
        // SignUp
        initialRouteName={"SignUp"}
      >
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Welcome" component={WelcomeScreen} />
 </Stack.Navigator>

@focux
Copy link

focux commented Apr 23, 2024

Yep, that's was my problem as well, having a wrong route name on initial route name.

@wiseqingyang
Copy link

In my case, I open my app by deep link like myappschema://someroute;
My routes looks like this

<Stack.Navigator initialRouteName="Home">
    {isLogin ? (
      <>
        <Stack.Screen name="Home" component={Home} />
        {/* some other routes */}
      </>
    ) : (
      <>
        <Stack.Screen name="Login" component={Login} />
        {/* some other routes */}
      </>
    )}
  </Stack.Navigator>

Yes, there is something wrong, when the user has login, the initialRouteName Home exists, but when the user hasn't login, the initialRouteName Home does not esxits.
So in my case, user who hasn't login will crash. while other users will not. This happens both on Android and iOS.

🚀 change my code initialRouteName={isLogin ? "Home" : "Login"} fixes my problem.

If someone wants to reproduce the problem, do the following:

  1. set initailRouteName to some route that not exists.
  2. kill the app process.
  3. boot the app route by deep link with a route

hope this save someone's time!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants