[v2] Pass setFieldValue in useField's returned value.
See original GitHub issue🚀 Feature request
Passing setFieldValue
in useField
’s meta returned value would be interesting for checkboxes.
An example:
const Checkbox = ({ name }) => {
const [field, meta] = useField(name)
return {
<input
type="checkbox"
checked={field.value}
name={field.name}
onChange={() => meta.setFieldValue(field.name, !field.value)}
/>
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Formik setFieldValue Inside a Function - Stack Overflow
That's where I need to set the field value from. I guess what I could do is pass the setFieldValue function as a...
Read more >useField() - Formik
2 import { useField, Form, FormikProps, Formik } from 'formik'; ... is a subset of the props that you would pass to <Field>...
Read more >Managing list of form fields with formik through example
value } </span> </div> ); };. Custom hooks are now part of formik >= v2 , useField hook returns a 3-tuple (an array ......
Read more >useForm - setValue - React Hook Form
This function allows you to dynamically set the value of a registered field and ... fields and remount with updated value update(0, {...
Read more >Top 5 formik Code Examples - Snyk
it('should return context with passed values', () => { const context ... will set value when before unmount, it's needed to wrap setFieldValue...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sumgwork you can use
useFormikContext
and getsetFieldValue
from thatUh 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.