Skip to content

Commit

Permalink
fix(FormikToggle): fix typing error in mapFieldToToggle
Browse files Browse the repository at this point in the history
  • Loading branch information
kevicency committed Dec 6, 2018
1 parent a71ef37 commit e5b112b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/FormikToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import { createFakeEvent, Omit } from './utils'

export function mapFieldToToggle<T = any>({
form,
field: { value, onChange, onBlur, ...field },
field,
}: FieldProps<T>): Pick<IToggleProps, 'checked' | 'onChange'> {
return {
...field,
onChange: (_, checked) => {
form.setFieldValue(field.name, checked)
onBlur(createFakeEvent(field))
field.onBlur(createFakeEvent(field))
},
checked: value,
checked: field.value,
}
}

Expand Down
1 change: 0 additions & 1 deletion src/__tests__/__snapshots__/FormikToggle.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ exports[`<FormikToggle /> renders correctly as a field component 1`] = `
className="ms-Toggle-background pill-50"
data-is-focusable={true}
id="Toggle1"
name="test"
onChange={[Function]}
onClick={[Function]}
role="switch"
Expand Down

0 comments on commit e5b112b

Please sign in to comment.