Last active
October 16, 2019 10:18
-
-
Save marcuszierke/5242b0aec88a75e2c762577685948562 to your computer and use it in GitHub Desktop.
React Contact Form without using state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
const ContactForm = () => { | |
const [newsletterValue, setNewsletterValue] = useState(false); | |
function changeNewsletterValue() { | |
setNewsletterValue(!newsletterValue); | |
} | |
... | |
return ( | |
<div> | |
<form> | |
... | |
<input | |
type="checkbox" | |
name="newsletter" | |
onClick={changeNewsletterValue} | |
value={newsletterValue} | |
/> | |
</form> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment