rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Add documentation for single file nested navigation structures

Open Laurensdc opened this issue 6 years ago • 1 comments

A navigation structure as described below works beautifully but isn't documented anywhere. It allows you to navigate from nested screens to other nested screens easily, without having to pass navigation props from one screen to another.

I feel like such an example should be documented, since it's been discussed in various issues: https://github.com/react-navigation/react-navigation/issues/1979 https://github.com/react-navigation/react-navigation/issues/983 https://github.com/react-navigation/react-navigation/issues/913 https://github.com/react-navigation/react-navigation/issues/335 https://github.com/react-navigation/react-navigation/issues/1127

and more...

export const AppNavigator = StackNavigator(
    {
        Login: {
            screen: LoginScreen,
        },
        SetPassword: {
            screen: SetPasswordScreen,
        },

        mainFlow: {
            screen: TabNavigator(
                {
                    overviewFlow: {
                        screen: StackNavigator(
                            {
                                Overview: {
                                    screen: OverviewScreen,
                                },
                                DietitianInfo: {
                                    screen: DietitianInfoScreen,
                                },
                            },
                            {
                                headerMode: 'none',
                            }
                        )
                    },
                    Goals: {
                        screen: GoalsScreen,
                    },
                    diaryFlow: {
                        screen: StackNavigator(
                            {
                                DiaryOverview: {
                                    screen: DiaryOverviewScreen,
                                },
                                DiaryEntry: {
                                    screen: DiaryEntryScreen,
                                },
                            },
                            {
                                headerMode: 'none',
                            }
                        )
                    },

                    Notes: {
                        screen: NotesScreen,
                    },
                },
                {
                    tabBarPosition: 'bottom',
                    navigationOptions: ({ navigation }) => ({
                        // ...                         
                    }),
                    tabBarOptions: {
                       // ...
                    },
                }
            )
        }
    },
    {
        headerMode: 'none',
        // onTransitionStart: (e) => {
        //     console.log('Navigating somewhere');
        //     console.log(e);
        // },
    }
);

Laurensdc avatar Mar 09 '18 13:03 Laurensdc