Skip to content

Instantly share code, notes, and snippets.

@wmonk
Last active April 4, 2017 15:33
Show Gist options
  • Save wmonk/79cfc022e5e90e99e54741152b3aaecb to your computer and use it in GitHub Desktop.
Save wmonk/79cfc022e5e90e99e54741152b3aaecb to your computer and use it in GitHub Desktop.
react-redux-form thoughts
// 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