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
Try using router.back() instead
import {router} from "expo-router";