Current Behavior
My form loads but the mapPropsToValues (or initialValues) don't appear despite my console.log actually showing that the profile object is filled out (some values are null which is fine).
Not to sure if it is my props typings that is the issue?
Expected behavior
Basically the form should look like so:
Additional context
My gist (withFormik.tsx)
hmmmm found this section in the example/docs
{/*
The benefit of the render prop approach is that you have full access to React's
state, props, and composition model. Thus there is no need to map outer props
to values...you can just set the initial values, and if they depend on props / state
then--boom--you can directly access to props / state.
The render prop accepts your inner form component, which you can define separately or inline
totally up to you:
- `<Formik render={props => <form>...</form>}>`
- `<Formik component={InnerForm}>`
- `<Formik>{props => <form>...</form>}</Formik>` (identical to as render, just written differently)
*/}
Looks like I might need to stick with the Formik component instead of the HoC, since I have mobx stores that I need to get initial values from for certain forms. Is this correct?
You need to be careful with enableReinitialize and mobx/redux and make sure you are only supplying exactly the props formik needs. Otherwise, your form will reset when an unwanted prop changes (even if you are not using it in your form).
Yeh sounds like I might need to only render the form once my mobx store is loaded with data so the initialValues are set then I am using the
Most helpful comment
You need to be careful with enableReinitialize and mobx/redux and make sure you are only supplying exactly the props formik needs. Otherwise, your form will reset when an unwanted prop changes (even if you are not using it in your form).