Skip to content

Instantly share code, notes, and snippets.

@marcuszierke
Last active October 16, 2019 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcuszierke/5242b0aec88a75e2c762577685948562 to your computer and use it in GitHub Desktop.
Save marcuszierke/5242b0aec88a75e2c762577685948562 to your computer and use it in GitHub Desktop.
React Contact Form without using state
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