Skip to content

Dispatch action not working.  #46

Description

@webacers

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions