Skip to content

Instantly share code, notes, and snippets.

@erikras
Last active December 3, 2017 16:16
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 erikras/08748a6e764f2449400aec9c34eb1032 to your computer and use it in GitHub Desktop.
Save erikras/08748a6e764f2449400aec9c34eb1032 to your computer and use it in GitHub Desktop.
🏁 Final Form Mutator Example
/** Clears a form value */
const clear = ([name], state, { changeValue }) => {
changeValue(state, name, () => undefined)
}
/** Converts a form value to uppercase **/
const upper = ([name], state, { changeValue }) => {
changeValue(state, name, value => value && value.toUpperCase())
}
const form = createForm({
onSubmit,
mutators: { clear, upper }
})
...
form.mutators.upper('foo')
...
form.mutators.clear('foo')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment