Last active
August 30, 2016 07:08
-
-
Save marr/a0b2d955c4c4e7c985bb96e96a46a98d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 renderInterest = (interest, i) => { | |
return ( | |
<div className="flexi" key={i}> | |
<label> | |
<Field name={`${interest}.selected`} component="input" type="checkbox" /> | |
<i /> | |
<Field name={`${interest}.name`} component={({ input }) => <span>{input.value}</span>} /> | |
</label> | |
</div> | |
) | |
} | |
const renderInterests = ({ fields }) => ( | |
<div> | |
{fields.map(renderInterest)} | |
</div> | |
) | |
<FieldArray component={renderInterests} name="interests" /> |
This file contains hidden or 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 classnames from 'classnames' | |
import React, { Component, PropTypes } from 'react' | |
class Label extends Component { | |
static propTypes = { | |
input: PropTypes.object.isRequired, | |
meta: PropTypes.object.isRequired | |
}; | |
render() { | |
const { children, className, input, meta: { error, touched }, labelClasses } = this.props | |
return ( | |
<label className={classnames(labelClasses, { invalid: touched && error })}> | |
{children} | |
<input type="text" {...input} className={className} /> | |
{touched && error && <div>{error}</div>} | |
</label> | |
) | |
} | |
} | |
export default Label |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment