Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatch action not working. #46

Open
webacers opened this issue May 2, 2020 · 1 comment
Open

Dispatch action not working. #46

webacers opened this issue May 2, 2020 · 1 comment

Comments

@webacers
Copy link

webacers commented May 2, 2020

I am trying to signup using an API and have modified the singup page as below;
signup.tsx

const login = async (e: React.FormEvent) => { e.preventDefault(); setFormSubmitted(true); if(!firstName) { setUsernameError(true); } if(!password) { setPasswordError(true); } if(username && password) { //await setIsLoggedIn(true); //await setUsernameAction(username); await userRegister(firstName, lastName, email, phone, password, gender); history.push('/', {direction: 'none'}); } };

user.actions.ts

`export const userRegister = (firstName: string, lastName: string, email: string, phone: string, password: string, gender: string) => async (dispatch: React.Dispatch) => {

dispatch(setLoading(true));
const user = await setUserRegisterData(firstName, lastName, email, phone, password, gender);
console.log(user);
dispatch(setIsLoggedIn(true));
dispatch(setUsername(user.email));
dispatch(setUserRegisterAction(user));
dispatch(setLoading(false));

};

export const setUsername = (username?: string) => async () => {
console.log(new Date().toString());
await setUsernameData(username);
return ({
type: 'set-username',
username
} as const);
};
`

the console is showing user but no other dispatch function showing the log and working.

Is there any solution?

@ghost
Copy link

ghost commented May 15, 2020

Having this exact issue. 2-3 hours of pain later, no solution yet :|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant