Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to destructure form input values from useFormikContext?

Tags:

formik

I am trying to destructure values to get specific value of the form inputs using useFormikContext()

I have done like:

const { values } = useFormikContext()    
const { name, age } = values  

but I'm getting error like:

Property 'name' does not exist on type 'unknown'

like image 435
fmsthird Avatar asked Jan 22 '26 20:01

fmsthird


1 Answers

Fixed it.

I'm using typescript, when I added the interface to the useFormikContext() the error was gone.

Did it like this: useFormikContext<ProfileFields>()

like image 141
fmsthird Avatar answered Jan 25 '26 23:01

fmsthird



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!