import React, { useState } from "react"; import { Link } from "react-router-dom"; const Login = props => { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [errors, setErrors] = useState([]); const handleSubmit = event => { event.preventDefault(); if (isValid()) { props.login(email, password); } }; const isValid = () => { const errors = []; if (!email.trim()) errors.push("email"); if (password.trim().length < 6 || password.trim().length > 128) errors.push("password"); setErrors(errors); return errors.length === 0; }; return (