0

thank you for taking time to read & answer this question. I'll give my best to explain the issue I'm having.

The HomeStack component holds bottom navigation for four screens. One screen that is giving me a headache is ProjectsStack

export const ProjectsStack = (): ReactElement => {
  return (
    <ProjectsStackNav.Navigator initialRouteName='ProjectsScreen' screenOptions={defaultScreenOptions}>
      <ProjectsStackNav.Screen name='ProjectsScreen' component={ProjectsScreen} />
      <ProjectsStackNav.Screen name='CompletedProjectsScreen' component={CompletedProjectsScreen} />
      <ProjectsStackNav.Screen name='ProjectTasksScreen' component={ProjectTasksScreen} />
      <ProjectsStackNav.Screen name='CompletedProjectsTasksScreen' component={ProjectTasksScreen} />
    </ProjectsStackNav.Navigator>
  );
};

As you can see the ProjectTasksScreen is a component that renders a project based on the props => if it's open it will render ProjectTasksScreen otherwise it will render CompletedProjectsTasksScreen which is basically the same screen (reusability at its finest lol)

In order to go to the CompletedProjectsTasksScreen, you need to come from ProjectTasksScreen.

Now, the issue is when you want to go back from CompletedProjectsTasksScreen it will not go to ProjectTasksScreen, rather it will navigate to the previous screen of ProjectTasksScreen which is ProjectsScreen.

Is there a better solution to this problem than refactoring everything into it's screen & component?

1 Answer 1

1

navigation.push method instead of navigation.navigate may resolve your issue https://reactnavigation.org/docs/navigating/#navigate-to-a-route-multiple-times

Sign up to request clarification or add additional context in comments.

1 Comment

Solves the back issue but got another one, this adds two screens to the stack & I have to click back two times :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.