Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 21, 2016 13:51
Show Gist options
  • Save bnhansn/664b434755fdb560045f6d9d38ac469d to your computer and use it in GitHub Desktop.
Save bnhansn/664b434755fdb560045f6d9d38ac469d to your computer and use it in GitHub Desktop.
// @flow
import React from 'react';
type Props = {
input: Object,
label?: string,
type?: string,
placeholder?: string,
style?: Object,
meta: Object,
}
const Input = ({ input, label, type, placeholder, style, meta }: Props) =>
<div style={{ marginBottom: '1rem' }}>
{label && <label htmlFor={input.name}>{label}</label>}
<input
{...input}
type={type}
placeholder={placeholder}
className="form-control"
style={style && style}
/>
{meta.touched && meta.error &&
<div style={{ fontSize: '85%', color: 'rgb(255,59,48)' }}>{meta.error}</div>
}
</div>;
export default Input;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment