ERROR in ./src/pages/Login.jsx 8:0-42
未找到的单元: 错误: 您试图进口项目弧/目录之外的产品。 rc/rc外的相对进口没有得到支持。
您可以将其移至弧/弧内,或与项目Node_modules/。
ERROR in /src/pages/login.jsx 9:0-52
未找到的单元: 错误: 页: 1 rc/rc外的相对进口没有得到支持。
您可以将其移至弧/弧内,或与项目Node_modules/。
Carloin.js
import { useEffect, useRef } from react ;
import { Link, useNavigate } from react-router-dom ;
import axios from axios ;
import useAuth from ../hooks/useAuth ;
import API_ENDPOINT from ../globals/apiEndpoint ;
import ../index1.css ;
import ../styles/global.css ;
import ../styles/Form.css ;
import Swal from sweetalert2
const Login = () => {
const emailInput = useRef();
const passwordInput = useRef();
const navigate = useNavigate();
const { login } = useAuth();
const submitHandler = async (event) => {
event.preventDefault();
const sendDataRequest = {
email: emailInput.current.value,
password: passwordInput.current.value,
};
try {
const response = await axios.post(API_ENDPOINT.LOGIN, sendDataRequest);
await Swal.fire({
title: Berhasil Login ,
text: Berhasil login, silahkan menikmati fitur yang ada ya ,
icon: success ,
showConfirmButton: false,
timer: 2000,
});
login(response.data);
navigate( / );
} catch (error) {
const errorMessage = error?.response?.data?.message;
Swal.fire({
title: Gagal Login ,
text: `${errorMessage}`,
icon: error ,
});
}
};
return (
<>
<div className="container py-5">
<div className="d-flex flex-column align-items-center justify-content-center my-5">
<form className="col-10 col-md-6 col-lg-4 py-4" onSubmit={submitHandler}>
<h1 className="form__title mb-5">Masuk</h1>
<div className="row mb-3">
<label htmlFor="emailInput" className="form-label">
Email
<input ref={emailInput} type="email" name="email" id="emailInput" className="form-control form__input mt-1" placeholder="Email Anda" required />
</label>
</div>
<div className="row mb-3">
<label htmlFor="passwordInput" className="form-label">
Password
<input ref={passwordInput} type="password" name="password" id="passwordInput" className="form-control form__input mt-1" placeholder="Masukkan Password" minLength={8} required />
<div id="passwordHelp" className="form-text">
Panjang password minimal 8 karakter.
</div>
</label>
</div>
<div className="row mb-3 mt-4">
<input type="submit" className="mx-auto btn btn-hotelify rounded-pill" value="Masuk" />
<p className="text-center mt-3">
Belum punya akun?
{ }
<Link to="/register" className="hotelify-link pl-2">Daftar</Link>
</p>
</div>
</form>
</div>
</div>
</>
);
};
export default Login;
useAuth.js
import { useContext } from react ;
import { AuthContext } from ../store/authContext ;
const useAuth = () => useContext(AuthContext);
export default useAuth;
apiEndpoint.js
import CONFIG from ./config ;
const API_ENDPOINT = {
LOGIN: `${CONFIG.BASE_URL}/login`,
CHECK_TOKEN: `${CONFIG.BASE_URL}/auth/token`,
};
export default API_ENDPOINT;
config.js
const CONFIG = {
BASE_URL: http://localhost:3000/ ,
};
export default CONFIG;
在我的道路上,我无法在两天内解决这一问题? help
(React Js) 未找到的单元: 错误: • 决 定