'How to scroll to top of the page when using Formik and Formik-Stepper for a multistep form

I would like the page to scroll to top when click Next to next Step



Solution 1:[1]

Add window.scrollTo(0, 0); at event onClick of button:

onClick={() => {setStep((s) => s - 1); window.scrollTo(0, 0);}}

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Tomir Schmite Jr.