다음과 같은 에러가 발생하는데 오타가 있는지 확인해봐도 잘 모르겠습니다.. 거의 다 왔는데 해결이 안되네요ㅜㅜㅜ
//import Axios from 'axios';
import React, {useState} from 'react'
import {useDispatch} from 'react-redux' // dispatch를 통해서 action을 취함. 그리고 redux로 감
import {loginUser} from '../../../_actions/user_action'
function LoginPage(props) {
const dispatch = useDispatch();
const [Email, setEmail] = useState(""); // hook에서 state를 만듬
const [Password, setPassword] = useState("");
const onEmailHandler = (event) => {
setEmail(event.currentTarget.value);
}
const onPasswordHandler = (event) => {
setPassword(event.currentTarget.value);
}
const onSubmitHandler = (event) => {
event.preventDefault(); // 새로고침 방지
// console.log('Email', Email);
// console.log('Password', Password);
let body = {
email: Email,
password: Password
}
dispatch(loginUser(body)) // _action 폴더에서 loginUser를 만들어줌
.then(response => {
if(response.payload.loginSuccess){
props.history.push('/'); // 페이지 이동 이런식으로 함
} else{
alert('Error');
}
});
}
return (
<div style={{
display: 'flex', justifyContent: 'center', alignItems: 'center',
width: '100%', height: '100vh'
}}>
<form style={{display:'flex', flexDirection: 'column'}}
onSubmit={onSubmitHandler}
>
<label>Email</label>
<input type="email" value={Email} onChange={onEmailHandler} />
<label>Password</label>
<input type="password" value={Password} onChange={onPasswordHandler} />
<br />
<button type="submit">
Login
</button>
</form>
</div>
)
}
export default LoginPage