Last active
April 4, 2017 15:33
-
-
Save wmonk/79cfc022e5e90e99e54741152b3aaecb to your computer and use it in GitHub Desktop.
react-redux-form thoughts
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
// Main.js | |
const AddressFields = () => ( | |
<Field name="email"> | |
{({ onChange, value, errors }) => <input onChange={onChange} value={value} />} | |
</Field> | |
); | |
export const checkout = () => ( | |
<Form name="checkout"> | |
<Section name="deliveryDetails"> | |
<AddressFields /> | |
</Section> | |
<Section name="billingDetails"> | |
<AddressFields /> | |
</Section> | |
</Form> | |
); | |
// Aside.js | |
const aside = ({ submitForm }) => ( | |
<div> | |
<button onClick={submitForm}>Submit</button> | |
</div> | |
); | |
export default connect( | |
f => f, | |
dispatch => ({ submitForm: () => dispatch(submitForm("MY_FORM")) }) | |
)(aside); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment