Skip to content

Instantly share code, notes, and snippets.

@johhansantana
Created July 18, 2017 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johhansantana/7fa183e607d466c80ffcee816d106ddf to your computer and use it in GitHub Desktop.
Save johhansantana/7fa183e607d466c80ffcee816d106ddf to your computer and use it in GitHub Desktop.
field for redux-form
const renderField = (field) => (
<div className="form-group">
<label htmlFor={field.input.name}>{field.label}</label>
<input
{...field.input}
id={field.input.name}
name={field.input.name}
className={`form-control ${field.meta.touched && field.meta.error ? 'error' : ''}`}
type={field.type}
/>
{field.meta.touched && field.meta.error &&
<span className="error">{field.meta.error}</span>}
</div>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment