English 中文(简体)
(React Js) 未找到的单元: 错误: 你试图进口
原标题:(React Js) Module not found: Error: You attempted to import

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) 未找到的单元: 错误: • 决 定

问题回答

暂无回答




相关问题
How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.

What is Node.js? [closed]

I don t fully get what Node.js is all about. Maybe it s because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The ...

Clientside going serverside with node.js

I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. ...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

热门标签