react native undefined is not an object -


i new react native, wondering why getting error undefined not object. im trying add second screen on button press in login.js

but cant start app cause of undefined not object pointing here const { navigate } = props.navigation;

thank guys

here code

const login = (props) => {      const { navigate } = props.navigation;       return (         <view style={styles.container}>  <view style={styles.img}>       <image source={require('./download.png')} />       </view> <view style={styles.but}>      <button   onpress={() => navigate ('qr')}   title="sign in"   color="#2f4f4f" /> </view>        </view>      ); }   login.navigationoptions = {     title: 'login', };   export default login 

here index.android.js

export default class task extends component {   render() {      const { navigation} = this.props;     return (       <login navigation={navigation }/>     )   } }  const simpleapp = stacknavigator({   home: {screen: login},   secondscreen: {screen: qr} }); 

i think issue cause wrong usage of navigator in 'index.android.js'.

try change 'index.android.js' below:

export default class task extends component {   render() {     return (       <simpleapp />     )   } }  const simpleapp = stacknavigator({   home: {screen: login},   secondscreen: {screen: qr} });  appregistry.registercomponent(yourappname, () => task); 

hope helps.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -