React navigation wtih redux

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

React navigation wtih redux



I am trying to use react navigation with redux in my RN app. I have a login button with the following on button press function:


onButtonPress()
const email, password = this.props;
this.props.loginUser( email, password )
.then(() =>
this.props.navigate('Home');
);



loginUser is an action that is dispatched by redux , this on button press function however is in my loginform component which i use as one of my screens in the main stack navigator, and I have tested it to make sure it works properly, however, I keep getting this error whenever I add the navigate function:
undefined is not an object (evaluating 'this.props.loginUser( email: email, password: password ).then')



However, if I have the navigation statement outside of the then statement, it works. I tried looking at other questions on stackoverflow and github but have found no solution that works, any help?



Here's what I get back when I console log (this.props):


Object "email": "n*********@gmail.com", "emailChanged": [Function anonymous], "error": "", "loading": false, "loginUser": [Function anonymous], "navigation": Object "actions": Object "dismiss": [Function dismiss], "goBack": [Function goBack], "navigate": [Function navigate], "pop": [Function pop], "popToTop": [Function popToTop], "push": [Function push], "replace": [Function replace], "reset": [Function reset], "setParams": [Function setParams], , "addListener": [Function addListener], "dangerouslyGetParent": [Function anonymous], "dismiss": [Function anonymous], "dispatch": [Function anonymous], "getChildNavigation": [Function getChildNavigation], "getParam": [Function anonymous], "getScreenProps": [Function anonymous], "goBack": [Function anonymous], "isFocused": [Function isFocused], "navigate": [Function anonymous], "pop": [Function anonymous], "popToTop": [Function anonymous], "push": [Function anonymous], "replace": [Function anonymous], "reset": [Function anonymous], "router": undefined, "setParams": [Function anonymous], "state": Object "key": "id-1532963235056-0", "routeName": "Login", , , "password": "******", "passwordChanged": [Function anonymous], "screenProps": undefined, "signUpUser": [Function anonymous],




1 Answer
1



Can you try this?


onButtonPress = async () =>
const email, password = this.props;
await this.props.loginUser( email, password )
this.props.navigate('Home');






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

PySpark count values by condition

Trying to Print Gridster Items to PDF without overlapping contents