'How to toggle react-navigation if there is two drawer?

I have spent most of the time trying to find out how to toggle right Drawer with react-navigation Ref?

currently, it toggles only with left drawer

navigationRef.getParent() or navigationRef.current.getParent() returns undefined

https://snack.expo.dev/@cmark1902/two-navigation-drawer



Solution 1:[1]

You can assign an id to a Drawer.Navigator instance like so: <Drawer.Navigator id="LeftDrawer" />. When calling getParent, you can pass in this 'id' field as an argument and chain the openDrawer() function like so: navigation.getParent("LeftDrawer").openDrawer(). This article in react navigation v6 docs explains it perfectly. https://reactnavigation.org/docs/multiple-drawers/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harrison Taee