Replies: 1 comment 2 replies
-
It's really not possible to debug this without a minimal codesandbox reproduction. I'd guess that the formOnSubmit function being passed to your parent form isn't stable. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey y'all,
So i have been working on this issue for about 3 days now and I have yet to find a solution. I currently have a parent component that contains a child component which houses the Formik form. Props are provided to the parent for the parent UI itself and the child UI as well. On submission of the form the parent props have 1 value that changes, this value is only used in the parent component and not in the child. Thus the child props undergo no change. However, regardless of that, the child component re-renders despite being memoized and all the form data is cleared.
This is unideal as the desired behavior is that when the form is submitted and there is no error, the form will display the notification to the user of a successful submit and clear the form (using refs and FormikProps, see comment under switch statement for statusCode 200). However when there is an error the form will display the notification to the user of an unsuccessful submit and leave the form untouched (so the user can save off their text they provided and try again later).
I cannot figure out why Formik re-renders when it is not necessary. None of the props are changing to the child, its been memoized and functions are using useEffect, there is no manual call to clear the form and enableReinitialize is set to false. I have tried adding keys to all child components thinking that might help but it didn't. Has anyone else experienced these issues?
Some background info on what is happening:
statusCode
prop, the others stay the same.areEqual
function in theReact.memo()
call does not get called on child re-render (when the form is cleared).Any and all help is appreciated!
Beta Was this translation helpful? Give feedback.
All reactions