<Formik
enableReinitialize
initialValues={testState}
validateOnChange
onSubmit={onSubmit}>
{(formProps) => {
formProps.dirty && !isEmpty(formProps.touched) && handleFormDirty();
return (
<TestComponent />
);
}}
</Formik>
handleFormDirty is a function from React context, which will change the state in React context. However, when I try to invoke handleFormDirty, it will show warnings like:
To locate the bad setState() call inside Formik
, follow the stack trace as described
I found a similar question here setState called in render prop is causing a react warning but it seems like the answer is not perfect.
Any ideas? Thanks a lot.