react-native-off-canvas-menu
react-native-off-canvas-menu copied to clipboard
Navigate programmatically
I need to navigate programmatically. Is it somehow possible? Even simulating a menu item press would be fine.
Yes, I am also trying to find a way to go to a screen with a button click. Is there a way to do that as it is now?
simply use a router. this package does not dictate any routing. try react-router
or it's alternatives. that would help.
Today I needed the same feature. It is so simple. For exemple:
<OffCanvasReveal
...
ref={component => this._OffCanvasReveal = component} {...this.props}
menuItems={[
{
title: 'Menu1',
renderScene: <Menu goToMenu={this.goToMenu.bind(this)}/>
}
]}
/>
"index" is the position in the property "menuItems " 0,1,2,3 and so one.
goToMenu(index) {
this._OffCanvasReveal.setState({activeMenu: index});
}
Call this function when you need: this.props.goToMenu(2)