Last active
April 15, 2019 14:40
-
-
Save WDever/4aa4fe533d63e79e59294846db172c65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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