Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

router.back(), not going to previous page, but rather to first Tab in Expo Tab navigator

In my _layout.tsx, I have a Tab navigator with all my different routes declared. Sometimes I want to redirect to a form, by using router.push("foo"), and then on submission, I call router.back(). Instead of redirecting me to the site that I was on before, it goes to the first tab in the Tab bar.

Note: I am using the router that I import like so import { router } from "expo-router";

Things I have tried:

  • Using useNavigation
  • Using useRouter
like image 933
Ziad Malik Avatar asked Jan 20 '26 15:01

Ziad Malik


1 Answers

<Tabs initialRouteName="my-child" backBehavior="history"

try adding backBehavior to "history" in your Tabs component.

like image 100
cwwkk Avatar answered Jan 23 '26 10:01

cwwkk