react-native-off-canvas-menu icon indicating copy to clipboard operation
react-native-off-canvas-menu copied to clipboard

Navigate programmatically

Open BenjiFarquhar opened this issue 7 years ago • 3 comments

I need to navigate programmatically. Is it somehow possible? Even simulating a menu item press would be fine.

BenjiFarquhar avatar Jun 19 '17 07:06 BenjiFarquhar

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?

moysidis avatar Aug 21 '17 09:08 moysidis

simply use a router. this package does not dictate any routing. try react-router or it's alternatives. that would help.

thg303 avatar Oct 12 '17 17:10 thg303

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)

lunardidev avatar Jul 26 '19 03:07 lunardidev