react-nativeexpo

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:


Solution

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

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