Created
December 5, 2017 05:07
-
-
Save aakashns/d3ee3e12ef5e35c811e3490c03d3a0f7 to your computer and use it in GitHub Desktop.
Connecting the contactForm reducer with a React component.
This file contains 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
const ContactForm = ({ data, editData }) => ( | |
<div> | |
<h4>Contact Form</h4> | |
<input | |
type="text" | |
value={data.name} | |
onChange={e => editData({ name: e.target.value })} | |
/> | |
<input | |
type="text" | |
value={data.email} | |
onChange={e => editData({ email: e.target.value })} | |
/> | |
<input | |
type="checkbox" | |
checked={data.subscribeToNewsletter} | |
onChange={e => editData({ subscribeToNewsletter: e.target.checked })} | |
/> | |
</div> | |
); | |
const mapStateToProps = state => ({ | |
data: state.contactForm | |
}); | |
const mapDispatchToProps = { | |
editData: editContactForm | |
}; | |
export default connect(mapStateToProps, mapDispatchToProps)(ContactForm); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment