Skip to content

TypeError: undefined is not an object (evaluating 'scene.descriptor') #10962

@russmenum

Description

@russmenum

Current behavior

I am updating our app and hitting an issue with code that was working before the upgrade for <Stack.Navigator />. This was working in a prior ver or RN and "@react-navigation/native": "^5.2.4".

Looks like the current ver is "@react-navigation/native": "^6.0.12",

For whatever reason on the authorised side some values are undefined now.

TypeError: undefined is not an object (evaluating 'scene.descriptor')

with respect to

<Stack.Navigator
              screenOptions={({ route, navigation }) => ({
                header: ({scene, previous, navigation}) => {
                  const {options} = scene.descriptor;
                  // const {headerTitleOverride: headerTitle} = options;

                  return (
                    <AuthorizedHeader
                      unauthorizedHeader={
                        route?.name !== "SignUp" && route?.name !== "Login"
                      }
                      showHeaderTitle={showHeaderTitle}
                      route={route}
                      sceneOptions={options}
                      headerTitleOverride={options?.headerTitle}
                      leftIcon={options?.leftIcon}
                      navigation={navigation}
                      showOrderControls={(location) => {
                        setShowOrderControls(!showOrderControls);
                        setControlLocation(location);
                      }}
                      showLocationChecker={() => {
                        setShowLocationChecker(true);
                      }}
                      orderControlExpanded={showOrderControls}
                    />
                  );
                },
                //anywhere except the account screen you can swipe right from the left side
                //of the screen to go back
                gestureEnabled: route.name !== "Account",
                gestureDirection: "horizontal",
                //transition animations
                cardStyleInterpolator:
                  route.name === "Account"
                    ? CardStyleInterpolators.forRevealFromBottomAndroid
                    : CardStyleInterpolators.forHorizontalIOS,
              })}
              headerMode={"screen"}
            >

All the error tells me is this value is undefined, and I am not fully following where it is meant to come from...

Expected behavior

I would expect the app to run at it did before all these updates

Instead, it crashes in the simulator once you log in because this value is undefined.

My guess is some update for how this value is passed has been overlooked, but I am not 100% sure where it is meant to come from...

Reproduction

SNAK is above in the Current behavior

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

Environment

  • [] I've removed the packages that I don't use
package version
@react-navigation/native ^6.0.12
@react-navigation/bottom-tabs ^6.4.0
@react-navigation/drawer non-present in the JSON
@react-navigation/material-bottom-tabs non-present in the JSON
@react-navigation/material-top-tabs non-present in the JSON
@react-navigation/stack ^6.2.3
@react-navigation/native-stack non-present in the JSON
react-native-safe-area-context ^4.3.3
react-native-screens ^3.17.0
react-native-gesture-handler ^2.6.1
react-native-reanimated ^2.11.0
react-native-tab-view non-present in the JSON
react-native-pager-view non-present in the JSON
react-native 0.69.5
expo ~46.0.9
node v15.6.0
npm or yarn 7.4.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions