android - React Native - passing refs into NavigationBar routeMapper -


i'm trying open drawer menu when clicking on left button in navigation bar (android). reason doesn't recognise refs when calling opendrawer

i error: "undefined not object (evaluating '_this3.refs.drawer')"

quite frustrating :/

how can open drawer routemapper?

class navigator extends component {   constructor(props){   super(props);  ...  }   renderscene(route, nav){  ...  }   static routemap = drawer => ({    leftbutton(route, navigator, index, navstate){     return (       <touchablehighlight onpress={() => {        this.drawer.opendrawer();       }}>        <text>menu</text>       </touchablehighlight>     );    },    rightbutton(route, navigator, index, navstate){     return null;    },    title(route, navigator, index, navstate){     return (      <view style={{flex:1}}>       <text style={styles.title}>{route.name}</text>      </view>     )    },  })  render(){  var navigationview = (       <view style={styles.page}>         <toolbarandroid style={styles.toolbar}         title="menu"         titlecolor="#fff" />         <view>         <touchablehighlight style={styles.button} onpress={() => {           this.nav.push({             name:'page1',           });           this.drawer.closedrawer();         }}>           <view>               <text style={styles.instructions}>                 page 1               </text>           </view>         </touchablehighlight>         <touchablehighlight style={styles.button} onpress={() => {           this.nav.push({             name: 'page2',           });           this.drawer.closedrawer();         }}>           <view>               <text style={styles.instructions}>                 page 2               </text>           </view>         </touchablehighlight>         </view>       </view>   );    return (           <drawerlayoutandroid           drawerwidth={300}           drawerposition={drawerlayoutandroid.positions.left}           ref={(ref) => this.drawer = ref }           rendernavigationview={() => navigationview}>             <navigator               initialroute={{name: 'page1', index: 0}}               ref = {((nav)=> { this.nav = nav; })}               renderscene={this.renderscene.bind(this)}               configurescene={(route, routestack) =>                 navigator.sceneconfigs.floatfrombottomandroid}               navigationbar={             <navigator.navigationbar routemapper={navigator.routemap(this.drawer)}             style={styles.toolbar} />             }                />           </drawerlayoutandroid>         );     } } 

eventually solved.

i added in main class.

opendrawer(){ drawer.opendrawer(); } 

then passed navigator.routemap(this.opendrawer) instead of this.drawer routemapper.

then inside routemapper called opendrawer(); , worked.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -