Open energizer91 opened 3 years ago
When settings enableReinitialize Formik renders twice (instead rendering once as it was in version 1.5.8 for example)
enableReinitialize
Formik should render once if nothing changed during first render
https://codesandbox.io/s/formik-codesandbox-template-forked-goq55 (open console and see how many render messages you see)
render
Probably, the problem is located here: https://github.com/formium/formik/blob/master/packages/formik/src/Formik.tsx#L166 Not sure why we need isMounted at all (and why it's ref and not state), even though checking isMounted in useEffect with additional props array (since it will be called only after first render)
isMounted
useEffect
Any news on this? Same problem as: https://stackoverflow.com/questions/73737311/formik-renders-twice-on-initialization
Bug report
Current Behavior
When settings
enableReinitialize
Formik renders twice (instead rendering once as it was in version 1.5.8 for example)Expected behavior
Formik should render once if nothing changed during first render
Reproducible example
https://codesandbox.io/s/formik-codesandbox-template-forked-goq55 (open console and see how many
render
messages you see)Suggested solution(s)
Probably, the problem is located here: https://github.com/formium/formik/blob/master/packages/formik/src/Formik.tsx#L166 Not sure why we need
isMounted
at all (and why it's ref and not state), even though checkingisMounted
inuseEffect
with additional props array (since it will be called only after first render)Additional context
Your environment