Skip to content

Instantly share code, notes, and snippets.

@pubudu-ranasinghe
Created November 3, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pubudu-ranasinghe/5519be3daff0ef9359932493434c5992 to your computer and use it in GitHub Desktop.
Save pubudu-ranasinghe/5519be3daff0ef9359932493434c5992 to your computer and use it in GitHub Desktop.
react-context-example-14
import React, { useState } from "react";
export default function Login() {
const [name, setName] = useState("");
const [loading, setLoading] = useState(false);
function handleLogin() {
// Handle login here
}
if (loading) return <p>Loading..</p>;
return (
<header className="App-header">
<h2>Login</h2>
<div className="Item">
<input
type="text"
placeholder="Name"
value={name}
onChange={e => setName(e.target.value)}
></input>
<button onClick={handleLogin}>Login</button>
</div>
</header>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment