Created
February 4, 2021 03:45
-
-
Save carmandomx/9bb6cc86d76ba85e7d23685e598687ad to your computer and use it in GitHub Desktop.
Clase: Eventos - Ejercicio Formulario
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 "./App.css"; | |
import React, { useState } from "react"; | |
function App() { | |
const [color, setColor] = useState("#e97878"); | |
const [user, setUser] = useState(""); | |
const [passwd, setPasswd] = useState(""); | |
const [isSubmitted, setIsSubmitted] = useState(false); | |
const handleLogin = (e) => { | |
e.preventDefault(); | |
setIsSubmitted(true); | |
console.log({ | |
user, | |
passwd, | |
}); | |
}; | |
return ( | |
<div | |
className="App" | |
style={{ | |
backgroundColor: color, | |
}} | |
> | |
{isSubmitted && ( | |
<p> | |
{" "} | |
User: {user} y Password: {passwd}{" "} | |
</p> | |
)} | |
<form onSubmit={(e) => handleLogin(e)}> | |
<input value={user} onChange={(e) => setUser(e.target.value)} /> | |
<input | |
value={passwd} | |
onChange={(e) => setPasswd(e.target.value)} | |
type="password" | |
/> | |
<button>Log in</button> | |
<button type="button">Cancel</button> | |
</form> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment