Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
React native. Back button redirect to the Home page

I have a tab with multiple components

const HomePageStack = createStackNavigator();
const HomePageScreen = () => (
    <HomePageStack.Navigator initialRouteName='Главная' screenOptions={{ headerShown: true, headerTransparent: true, headerTintColor: '#fff', headerTitleStyle: { color: 'rgba(0, 0, 0, 0)' }, }}>
        <HomePageStack.Screen name='Главная' component={Home} options={{ title: "Главная" }} style={{ height: '100%' }} />
        <HomePageStack.Screen name='Рецепт' component={Recipe} option={{ title: 'Рецепт' }} style={{ height: '100%' }} />
        <HomePageStack.Screen name='Аккаунт' component={Account} option={{ title: 'Аккаунт' }} style={{ height: '100%' }} />
    </HomePageStack.Navigator>
)

When checking, I go this way (using navigation.navigate with data)

Home -> Recipe -> Account -> Recipe

Back Button works fine until I switch to the Recipe a second time

When I go to the Recipe for the second time and click back button, I am sent to the main page, but I want to be in the Account

I have not customized or changed how the back button works.

Redirect function (from Account to Recipe 2):

const handleRecipe = (_id) => {
    navigation.navigate('Рецепт', { _id })
}

I want the back button to work as expected and redirect the user to the Account and not to the Home page. I suspect the problem is with my redirect function.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

navigate pops back to earlier in the stack because the Recipe screen is already present there. To push another instance of Recipe on the navigation stack you can use the push action instead. So on the Account screen you use the push action instead of the navigate action to avoid going back to the already present Recipe screen. See https://reactnavigation.org/docs/stack-actions/#push for an example.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!