Home.js into LogIn

 //========Home.js=========


import React,{useState} from "react";
import {useNavigate} from "react-router-dom";


export default function () {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");

const navigate=useNavigate();


const handleSubmit = (e) => {
e.preventDefault();
localStorage.setItem("email", email);
localStorage.setItem("password", password);
// window.location.href="/contact";
navigate("/contact");
};

return <>
<h1>Home Page</h1>
<h3>Login Form</h3>
<div>
<input
type="email"
placeholder="Enter Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
style={{ width: "100%", padding: "8px", marginBottom: "10px" }}
/>
<input
type="password"
placeholder="Enter Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
style={{ width: "100%", padding: "8px", marginBottom: "10px" }}
/>
<button onClick={handleSubmit} type="submit" style={{ padding: "8px 20px", cursor: "pointer" }}>
LogIn
</button>
</div>
<p><b>Stored Email:</b> {localStorage.getItem("email") || "N/A"}</p>

</>
}

Comments

Popular posts from this blog

App 1st User Define Component

Example 1

Rabiit