'Reset Formik fields from parent component in React

I am using Formik for form validation in React application. My Parent component (Users) - displays list of users. If we select any user, details of the user will be displayed in another component to the right side in a form. The child component (UserDetails) displays the details of the selected user. All the details are displayed in textboxes in child component, which we can change and update the details(Here I am using FORMIK to validate fields before updating).

I have a scenario where I am trying to clear all fields (reset form values of UserDetails) on clicking a button from parent component (Users). I am trying to change the initial values of the Formik Form from parent component. Some how its not working for me.

I want to clear all fields of a Formik Form from it's parent component.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source