Answer the question
In order to leave comments, you need to log in
How to catch menu click event in React Native Drawer Navigation?
I need to pass a parameter to the screen, but I did not find how to do it. How can I display not just a screen, but a screen with parameters when choosing a certain menu? In the example, I have the option Politics, Economy and Home page - they all lead to one screen, but I need to pass a parameter so that when I click on the policy button in that screen, only articles about politics will be displayed. How to do this?
const PostNavigator = createStackNavigator(
{
Main: MainScreen,
Post: PostScreen
},
navigatorOptions
)
const AboutUsNavigator = createStackNavigator(
{
AboutUs: AboutUsScreen
},
navigatorOptions
)
const AboutRedNavigator = createStackNavigator(
{
AboutRed: AboutRedScreen
},
navigatorOptions
)
const MainNavigator = createDrawerNavigator(
{
Main: {
screen: PostNavigator,
navigationOptions: {
drawerLabel: 'Главная'
}
},
Category_Politik: {
screen: PostNavigator,
navigationOptions: {
drawerLabel: 'Политика'
}
},
Category_Ekonomik: {
screen: PostNavigator,
navigationOptions: {
drawerLabel: 'Экономика'
}
},
AboutUs: {
screen: AboutUsNavigator,
navigationOptions: {
drawerLabel: 'Об издании'
}
}
},
{
initialRouteName: 'Main',
drawerBackgroundColor: '#D2D2D2',
}
)
export const AppNavigation = createAppContainer(MainNavigator)
Answer the question
In order to leave comments, you need to log in
Alternatively, you can pass parameters
navigation.navigate('Details', {
itemId: 42,
otherParam: 'anything you want here',
});
<Stack.Screen
name="Details"
component={DetailsScreen}
initialParams={{ itemId: 42 }}
/>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question