Skip to content

Instantly share code, notes, and snippets.

@WDever
Last active April 15, 2019 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WDever/4aa4fe533d63e79e59294846db172c65 to your computer and use it in GitHub Desktop.
Save WDever/4aa4fe533d63e79e59294846db172c65 to your computer and use it in GitHub Desktop.
public handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
const { login } = this.props;
const { id, password } = this.state;
e.preventDefault();
console.log(this.props);
await login({ id, password }); // redux-saga를 이용해 api 요청을 하는 함수. LOGIN 액션.
await this.afterLogin(); // 로그인 요청 이후 실행될 함수
};
public afterLogin = () => {
const { history, loginStatus } = this.props;
console.log(loginStatus); // 로그인 요청 상태
if (loginStatus === 'success') { // 성공시
console.log(loginStatus);
history.push('/');
} else if (loginStatus === 'failure') { //
console.log(loginStatus);
alert('로그인 실패');
history.push('/');
}
console.log(loginStatus);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment