react-navigation / react-navigation/react-navigation.github.io

elements left in stack

Open
#542 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
324
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

I want to check number of elements in my react navigation stack. if there was only one screen left and user press back button, application show them a message to exit the app. I had to use BackHandler in all of my screens because I hadn't had found a property which could show elements in stack.
this is my routes

const route1= {
	screen1,
	screen2
};

const route2= {
        screen3,
	screen4
};

export const stack1= createStackNavigator(route1);
export const stack2= createStackNavigator(route2);

export default {stack1, stack2};

this is my navigator

createNavigator = (routeName, params) => {
		this.navigator = createAppContainer(createSwitchNavigator(routes, { initialRouteName: routeName, initialRouteParams: params }));
	}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the createStackNavigator and createSwitchNavigator entry points shown in the issue, along with React Native's BackHandler context. Determine whether the documentation should explain how to detect a single remaining screen and handle the exit prompt; done means the supported approach is documented with an example matching the stack1/stack2 setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, react-native
Domain
documentation, mobile-dev
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.