Passing setFieldValue in useField's meta returned value would be interesting for checkboxes.
An example:
```js
const Checkbox = ({ name }) => {
const [field, meta] = useField(name)
return {
type="checkbox"
checked={field.value}
name={field.name}
onChange={() => meta.setFieldValue(field.name, !field.value)}
/>
}
}
Checkboxes are now handled out of the box though.
Uh I should start reading the change logs. I guess it would still be useful for using with other libraries like react-select, but I guess that might be an edge cases you don't want to cover.
Any chance of this to be reconsidered? It would be a great addition exactly for the reason @Ericnr mentioned above. Now I have to pass setFieldValue and setFieldTouched to every select because react-select handles event onChange differently.
<Select
name="instanceType"
setFieldValue={setFieldValue}
setFieldTouched={setFieldTouched}
...
/>
I am creating a material UI based components library, and want to integrate some custom form elements with Formik 2. As of now I have to pass setFieldValue and setFieldTouched manually when I use the useFormik hook to obtain form props. If these values can be provided by the hook itself, it can save the trouble of passing these values down the component chain.
@sumgwork you can use useFormikContext and get setFieldValue from that
Most helpful comment
@sumgwork you can use
useFormikContextand getsetFieldValuefrom that