const initialState = { name: "", email: "", mobile: "", subject: "", message: "", }; const [formData, setFormData] = useState(initialState); const newsletterHandler = (e) => { e.preventDefault(); console.log(formData); window.location.href = "mailto:info@gmail.com?" + "&body=" + "Name : " + formData.name + "%0D" + "Email : " + formData.email + "%0D" + "Mobile : " + formData.mobile + "%0D" + "Subject : " + formData.subject + "%0D" + "Message : " + formData.message; setTimeout(() => { setFormData(initialState); }, 3000); };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter