Dataset/JS/ReactSignUp/form.js (19 lines of code) (raw):
import React, { PropTypes } from 'react';
import { Input } from 'react-bootstrap';
export const FormGroup = props => {
const { field } = props;
let bsStyle;
if (field.touched) {
bsStyle = field.error ? 'error' : 'success';
}
return (
<Input hasFeedback={field.touched} bsStyle={bsStyle}>
{props.children}
{field.touched && field.error && <span className="help-block">{field.error}</span>}
</Input>
);
};
FormGroup.propTypes = {
field: PropTypes.object.isRequired,
children: PropTypes.object.isRequired,
};