How to destructure form input values from useFormikContext?

Viewed 4116

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'

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>()

Related