Last active
December 17, 2019 16:52
-
-
Save lucas-moraes/94058f100f22b4a1c463f42d2aee75c8 to your computer and use it in GitHub Desktop.
ReactJS - InputPass with eye magic button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
import { InputPassword, ButtonViewPassword } from "../globalStyles"; | |
const InputPass = () => { | |
const [type, setType] = useState("password"); | |
function toggle(e) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
setType(type === "text" ? "password" : "text"); | |
} | |
return ( | |
<div> | |
<InputPassword type={type} /> | |
<ButtonViewPassword onClick={toggle}>Ver</ButtonViewPassword> | |
</div> | |
); | |
}; | |
export default InputPass; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment