react-nativereact-navigationreact-navigation-drawer

getOptions for react navigation


React navigation has a well documented setOptions. https://reactnavigation.org/docs/navigation-prop

However I can't seem to find any method to retrieve the current options for the active navigator. Am I missing something? Or is there a reason why it may be private?

In particular I'm interested in getting the drawerType option out of Drawer navigator.


Solution

  • I just found these two handy methods.

    
      nav.getCurrentOptions()
      nav.addListener('options', () => {
        
      })
    

    they are both available on the NavigationContainerRef, which you can obtain via createNavigationContainerRef()