Search code examples
iosreact-nativenavigation-drawerstack-navigator

Refresh a screen after state change [Drawer navigator react-native]


I have a DrawerNavigator in StackNavigator. I have implemented the structure to achieve Hamburger menu function. I have a listing home page with a hamburger menu icon. On clicking the icon, I open a menu just like how it is in Amazon, flipkart apps. The menu list is dynamic, I need to refresh the list on state change.

Here is my view hierarchy:

export const DrawerMenu = DrawerNavigator({
    Search: {
        screen: Search,
    },
    SidebarMenuComponent: {
        screen: SidebarMenuComponent,
        navigationOptions: {
            headerTitle: Logo,
        }
    },
  }, {
    contentComponent: SidebarMenuComponent,
    drawerWidth: 250,
    drawerPosition: 'left',
    drawerOpenRoute: 'DrawerOpen',
    drawerCloseRoute: 'DrawerClose',
    drawerToggleRoute: 'DrawerToggle',
  });

const RootStack = StackNavigator({ 

    Search: {
        screen: DrawerMenu,
        navigationOptions: {
            headerTitle: Logo,
        }
    },

    ThankYou: {
        screen: ThankYou,
        navigationOptions: {
            headerTitle: 'ThankYou',
            gesturesEnabled: false,
        }
    },
  });

I am not able to reload it. So my question here is, how can we force to reload the list for this situation? Any help would be appreciated.

Thank you.


Solution

  • I am answering my own question.

    I fixed the issue by importing SidebarMenuContainer and assigned it to contentComponent instead of SidebarMenuComponent.