react native - navigation.goBack() not working in expo 52 - Stack Overflow

I upgraded my expo react native app from expo sdk 51 to sdk 52Fixed some minor errors but one came up

I upgraded my expo react native app from expo sdk 51 to sdk 52 Fixed some minor errors but one came up and I cannot find the solution anywhere.

<NavigationContainer>
          <Stack.Navigator
            initialRouteName={
              storedCredentials ? "ErrandLandingScreen" : "OnboardingScreen"
            }
            screenOptions={({ navigation }) => ({
              headerShown: false,
              headerShadowVisible: false,
              headerTitle: "",
              headerTitleAlign: "center",
              headerStyle: {
                backgroundColor: colors.white,
                paddingHorizontal: 20,
              },
              animation: "fade",
              headerLeft: (props) => (
                <TouchableOpacity
                  {...props}
                  onPress={() => navigation.goBack()}
                  
                >
                  <Ionicons name="chevron-back-outline" size={23} />
                </TouchableOpacity>
              ),
            })}
          >
    //screens go here
    </Stack.Navigator>
    </NavigationContainer>

Above is my code. But the navigation.goBack() is not working again after the upgrade. Please help

I upgraded my expo react native app from expo sdk 51 to sdk 52 Fixed some minor errors but one came up and I cannot find the solution anywhere.

<NavigationContainer>
          <Stack.Navigator
            initialRouteName={
              storedCredentials ? "ErrandLandingScreen" : "OnboardingScreen"
            }
            screenOptions={({ navigation }) => ({
              headerShown: false,
              headerShadowVisible: false,
              headerTitle: "",
              headerTitleAlign: "center",
              headerStyle: {
                backgroundColor: colors.white,
                paddingHorizontal: 20,
              },
              animation: "fade",
              headerLeft: (props) => (
                <TouchableOpacity
                  {...props}
                  onPress={() => navigation.goBack()}
                  
                >
                  <Ionicons name="chevron-back-outline" size={23} />
                </TouchableOpacity>
              ),
            })}
          >
    //screens go here
    </Stack.Navigator>
    </NavigationContainer>

Above is my code. But the navigation.goBack() is not working again after the upgrade. Please help

Share Improve this question asked Nov 16, 2024 at 8:48 ReoReo 1232 silver badges10 bronze badges 3
  • Actually it turns out the headerleft or headerright just isn't clickable again That is why it does not work – Reo Commented Nov 16, 2024 at 18:06
  • Do you know how to fix the header not clickable problem? – user2054522 Commented Dec 5, 2024 at 8:21
  • headerLeft and headerRight is clickable, but it does not work. github/expo/expo/issues/32927 – user2573099 Commented Dec 6, 2024 at 4:11
Add a comment  | 

1 Answer 1

Reset to default 0

Try using router.back() instead

import {router} from "expo-router";

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745662385a4638915.html

相关推荐

  • react native - navigation.goBack() not working in expo 52 - Stack Overflow

    I upgraded my expo react native app from expo sdk 51 to sdk 52Fixed some minor errors but one came up

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信