question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: disable drawer programatically

See original GitHub issue

Hi,

I would like to disable the drawer on some screens and reactivate it after in other screens, something like:

_drawerRef.setDisableProp(true|false)

I know I can do programatically close or open, but I would like to keep the close on tap gesture, and if possible the drag as well.

Thanks

Fx

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
stephensprinkle-zzcommented, Feb 12, 2016

@fxhereng

Came up against this scenario as well recently and there’s not need for a change to react-native-drawer itself – simply utilizing state should get things working as intended.

In my case things were similar, the drawer was the parent component of my react native router flux component.

Handled as follows (terse, just showing the relevant bits):

class <classname> extends Component{
  constructor(props){
    this.state = {
      drawerDisabled: true
    }

    this.disableDrawer = this.disableDrawer.bind(this)
    this.enableDrawer = this.enableDrawer.bind(this)
  }

  disableDrawer(){
    this.setState({
      drawerDisabled: true
    })
  }

  enableDrawer(){
    this.setState({
      drawerDisabled: false
    })
  }

  render(){
    return(
      <Drawer disabled={this.state.drawerDisabled}>
       <Router>
        <Route name='something' 
          component={Something} 
          disableDrawer={this.disableDrawer} 
          enableDrawer={this.enableDrawer} />
       </Router>
      </Drawer>
    )
  }
}

With this in place, you can then call the disable and enable props from within the child component(s).

0reactions
stephensprinkle-zzcommented, May 12, 2016

Even better! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable swipe gesture from opening the navigation drawer ...
The drawer may still be opened and closed programmatically ... This will disable swipe to open while keeping swipe to close enabled.
Read more >
Ability to disable Drawer edge-swipe · Issue #31127 - GitHub
I created a new issue to track a feature request for enabling a drawer ... Given that the drawer can only be opened...
Read more >
Drawer Navigator | React Navigation
Component that renders a navigation drawer which can be opened and closed via gestures. ... It can be closed normally using gestures or...
Read more >
DrawerLayout | Android Developers
DrawerLayout acts as a top-level container for window content that allows for interactive "drawer" views to be pulled out from one or both...
Read more >
Fragment Navigation Drawer | CodePath Android Cliffnotes
To use the Toolbar as an ActionBar , you need to disable the default ActionBar . This can be done by setting the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found