ionic-team / ionic-team/ionic-react-conference-app
Dispatch action not working.
- Dominant language
- TypeScript
- Stars
- 528
- Forks
- 212
- Avg merge
- 14h 53m
- Merged PRs (30d)
- 10
Description
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?
Contributor guide
Assessment
This issue has not been assessed yet.