import { useState } from "react"; import toast from "react-hot-toast"; // Assignment 5 — Subscription form. // The email is not sent to a real service yet. // A valid email shows a success toast and clears the input. function Subscription() { // TODO: Create state for the newsletter email input. const [, ] = useState(""); const handleSubmit = (event) => { event.preventDefault(); if (!email.includes("@")) { toast.error("Please enter a valid email address."); return; } toast.success(`Thanks! We'll send updates to ${email}.`); // TODO: Reset the email state so the input becomes empty again. }; return (
Subscribe to our newsletter for fresh restaurant recommendations delivered to your inbox.