Last active
December 3, 2017 16:16
-
-
Save erikras/08748a6e764f2449400aec9c34eb1032 to your computer and use it in GitHub Desktop.
π Final Form Mutator Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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