Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
  2. const { login } = this.props;
  3. const { id, password } = this.state;
  4. e.preventDefault();
  5.  
  6. console.log(this.props);
  7.  
  8. await login({ id, password }); // redux-saga를 이용해 api 요청을 하는 함수. LOGIN 액션.
  9.  
  10. await this.afterLogin(); // 로그인 요청 이후 실행될 함수
  11. };
  12.  
  13. public afterLogin = () => {
  14. const { history, loginStatus } = this.props;
  15.  
  16. console.log(loginStatus); // 로그인 요청 상태
  17.  
  18. if (loginStatus === 'success') { // 성공시
  19. console.log(loginStatus);
  20. history.push('/');
  21. } else if (loginStatus === 'failure') { //
  22. console.log(loginStatus);
  23. alert('로그인 실패');
  24. history.push('/');
  25. }
  26. console.log(loginStatus);
  27. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement