import { useState } from 'react' export default function Login({ onLogin }) { const [user, setUser] = useState('') const [pass, setPass] = useState('') const [error, setError] = useState('') const [loading, setLoading] = useState(false) async function handleSubmit(e) { e.preventDefault() setError('') setLoading(true) try { await onLogin(user, pass) } catch { setError('Invalid username or password') } finally { setLoading(false) } } return (

Dataflow

setUser(e.target.value)} className="w-full border border-line rounded px-3 py-2 text-sm focus:outline-none focus:border-accent" required />
setPass(e.target.value)} className="w-full border border-line rounded px-3 py-2 text-sm focus:outline-none focus:border-accent" required />
{error &&

{error}

}
) }