dispatch/client/src/js/components/ui/Checkbox.js

31 lines
653 B
JavaScript
Raw Normal View History

2018-05-16 03:02:48 +00:00
import React from 'react';
import { Field } from 'formik';
const Checkbox = ({ name, label, onChange, ...props }) => (
<Field
name={name}
render={({ field, form }) => (
<label htmlFor={name}>
{label && <div>{label}</div>}
<input
type="checkbox"
id={name}
name={name}
checked={field.value}
onChange={e => {
form.setFieldTouched(name, true);
field.onChange(e);
if (onChange) {
onChange(e);
}
}}
{...props}
/>
2018-06-10 19:25:58 +00:00
<span />
2018-05-16 03:02:48 +00:00
</label>
)}
/>
);
export default Checkbox;