2018-11-04 06:22:46 +00:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
import { FastField } from 'formik';
|
2018-10-15 06:56:17 +00:00
|
|
|
import Checkbox from 'components/ui/Checkbox';
|
|
|
|
|
|
|
|
const FormikCheckbox = ({ name, onChange, ...props }) => (
|
2018-11-04 06:22:46 +00:00
|
|
|
<FastField
|
2018-10-15 06:56:17 +00:00
|
|
|
name={name}
|
2018-11-04 06:22:46 +00:00
|
|
|
render={({ field, form }) => {
|
|
|
|
return (
|
|
|
|
<Checkbox
|
|
|
|
name={name}
|
|
|
|
checked={field.value}
|
|
|
|
onChange={e => {
|
|
|
|
form.setFieldTouched(name, true);
|
|
|
|
field.onChange(e);
|
|
|
|
if (onChange) {
|
|
|
|
onChange(e);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}}
|
2018-10-15 06:56:17 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2018-11-04 06:22:46 +00:00
|
|
|
export default memo(FormikCheckbox);
|