react-navigation not working, props is undefined -


i building poc application in react-native , trying implement react-navigation

import {stacknavigator, drawernavigator} 'react-navigation';  export default class homescreen extends react.component {     constructor(props) {         super(props)         this.clicked = this.clicked.bind(this)     }      static navigationoptions = {         drawerlabel: 'home',     };      clicked = ()=> {         this.props.navigator.navigate('draweropen'); // open drawer     }      render() {         // const {navigate} = this.props.navigation;         return (             <scrollview>                 <view style={styles.container}>                      <view style={styles.header}>                         <view style={{width: 50}}>                             <touchablehighlight onpress={()=> {                                 this.clicked("draweropen")                             }}>                                 <image source={require('./img/hamburger_icon.png')}/>                             </touchablehighlight>                         </view>                     </view>                </view>            </scrollview >        )     }  } 

now whenever clicking on touchable highlight, clicked function gets called , shows error:

undefined not object (evaluating '_this.props.navigator.navigate') clicked 

you try :)

 import {stacknavigator, drawernavigator} 'react-navigation';      export default class homescreen extends react.component {          static navigationoptions = {             drawerlabel: 'home',         };          clicked = () => {             this.props.navigation.navigate('draweropen'); // open drawer         }          render() {             // const {navigate} = this.props.navigation;             return (                 <scrollview>                     <view style={styles.container}>                          <view style={styles.header}>                             <view style={{width: 50}}>                                 <touchablehighlight onpress={()=>                                     this.clicked()                                 }>                                     <image source={require('./img/hamburger_icon.png')}/>                                 </touchablehighlight>                             </view>                         </view>                    </view>                </scrollview >            )         }      } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -