Skip to content

Instantly share code, notes, and snippets.

@danielkcz
Last active February 13, 2019 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielkcz/4f84bd77bfef4e743d879212aa53c923 to your computer and use it in GitHub Desktop.
Save danielkcz/4f84bd77bfef4e743d879212aa53c923 to your computer and use it in GitHub Desktop.
Formik with MobX #3
const formik = mobx.observable({
values: props.initialValues || {},
touched: {},
errors: {},
// scalar values needs to be wrapped into another object
// otherwise after spreading MobX would lost track of it
state: {
isSubmitting: false,
submitError: null
}
})
return { getFieldProps, ...formik };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment