Last active
September 23, 2017 18:51
-
-
Save KTruong008/01ea791aad93dd8075b83331eb504b3f to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
import { Field } from 'redux-form'; | |
import Text from '../components/text'; | |
import Select from '../components/select'; | |
import Radio from '../components/radio'; | |
import Checkbox from '../components/checkbox'; | |
export const FormComponent = ({ handleSubmit, onSubmit, formValues }) => { | |
return ( | |
<div className="flex flex-column justify-center items-center"> | |
<h1>My Very own Form</h1> | |
<form | |
className="w-80" | |
onSubmit={handleSubmit(onSubmit)} | |
> | |
... | |
<Field | |
name="spiceLevel" | |
label="Spice Level" | |
component={Radio} | |
options={{ | |
mild: 'Mild', | |
medium: 'Medium', | |
hot: 'hot' | |
}} | |
/> | |
{formValues && formValues.spiceLevel === 'hot' ? ( | |
<Field | |
name="wantsFries" | |
label="Would you like fries with that?" | |
component={Checkbox} | |
/> | |
) : ''} | |
<button | |
type="submit" | |
className="link br2 bg-blue white dim pa3 f6 sans-serif b--blue ba" | |
> | |
Submit | |
</button> | |
</form> | |
</div> | |
); | |
} | |
export default FormComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment