I’m experiencing an issue with a Formik form in my React application. When I submit the form using Formik on an iPhone’s Chrome browser, the form resets automatically without any explicit call to resetForm
. This behavior is inconsistent, as it does not occur on other browsers or on desktop devices.
Details:
- Frameworks/Libraries: React, Formik
- Browser: Chrome on iPhone
- Expected Behavior: After form submission, the form should not reset unless
resetForm
is called explicitly. - Actual Behavior: The form resets immediately upon submission without calling
resetForm
.
Code Snippet:
import React from 'react';
import { Formik, Form, Field } from 'formik';
const MyForm = () => {
return (
<Formik
initialValues={{ name: '' }}
onSubmit={(values) => {
console.log('Form values:', values);
// No resetForm call here
}}
>
{({ isSubmitting }) => (
<Form>
<Field type="text" name="name" placeholder="Name" />
<button type="submit" disabled={isSubmitting}>
Submit
</button>
</Form>
)}
</Formik>
);
};
export default MyForm;
Steps to Reproduce:
- Open the application on an iPhone’s Chrome browser.
- Fill out the form field.
- Submit the form.
- Observe that the form resets automatically without any explicit
resetForm
call.
Troubleshooting Attempts:
- Ensured no
resetForm
call is present in the submit handler. - Checked for any form reset side effects but found none.
- Verified the issue is specific to iPhone Chrome browser, as it works correctly on other browsers and desktop devices.
Questions:
- Has anyone encountered similar behavior with Formik on iPhone’s Chrome browser?
- Are there any known issues or workarounds for this specific browser/device combination?
Any help or suggestions would be greatly appreciated!