diff --git a/src/Pages/Login/Login.js b/src/Pages/Login/Login.js index a542879..34a3de6 100644 --- a/src/Pages/Login/Login.js +++ b/src/Pages/Login/Login.js @@ -72,22 +72,12 @@ function Login() { const [login, setLogin] = useState(loginInfos); const { email, password } = login; - const [toggleEye, setToggleEye] = useState(); const [isPasswordVisible, setIspasswordVisible] = useState(false); - const inputRef = useRef(null); const showPassword = () => { - const passwordInput = inputRef.current.firstElementChild.firstElementChild; - - if (!isPasswordVisible) { - setIspasswordVisible(true); - passwordInput.setAttribute("type", "password"); - setToggleEye(); - } else { - setIspasswordVisible(false); - passwordInput.setAttribute("type", "text"); - setToggleEye(); - } + isPasswordVisible + ? setIspasswordVisible(false) + : setIspasswordVisible(true); }; const handleLoginChange = (e) => { @@ -128,16 +118,20 @@ function Login() { type="email" onChange={handleLoginChange} /> -
+
- {toggleEye} + {isPasswordVisible ? ( + + ) : ( + + )}