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
Post a Comment