Formik: FastField doesn't set initial value with type="checkbox"

Created on 19 Feb 2020  路  5Comments  路  Source: formium/formik

馃悰 Bug report

Current Behavior

When using FastField and a checkbox's initial value is true the checkbox isn't checked. The code sandbox shows that Field works but FastField doesn't.

Expected behavior

Checked on true

Reproducible example

Edit Formik FastField checkbox bug

Your environment

| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 2.1.4
| React | 16.12
| TypeScript |
| Browser | Safari, Chrome
| npm/Yarn | yarn 1.22
| Operating System | macOS Catalina

Bug

All 5 comments

You must set checked={props.values.fastField}

Edit Formik FastField checkbox bug

That works but is it a workaround? I thought Field and FastField should act the same other than if the component should update? If you look at my original example Field works just fine without using the checked=value but FieldFast doesn't. I would think you could switch FastField and Field have the same functionality (other than if component should update).

Maybe they forgot to implement for type="checkbox"

FastField define "field" props in different way than Field, and it's looks lik not complet:

https://github.com/jaredpalmer/formik/blob/c85d85a3b6236a30034e73f8b821a280de8856b0/packages/formik/src/FastField.tsx#L140-L148

value is set to undefined, but checked is not set for this cases....

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredpalmer picture jaredpalmer  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

najisawas picture najisawas  路  3Comments

dfee picture dfee  路  3Comments

PeerHartmann picture PeerHartmann  路  3Comments