Skip to content

Instantly share code, notes, and snippets.

@marr
Last active August 30, 2016 07:08
Show Gist options
  • Save marr/a0b2d955c4c4e7c985bb96e96a46a98d to your computer and use it in GitHub Desktop.
Save marr/a0b2d955c4c4e7c985bb96e96a46a98d to your computer and use it in GitHub Desktop.
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" />
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