Created
December 11, 2017 11:17
-
-
Save erikras/f672c9bd3f01dad34b4a48afe7681b2b to your computer and use it in GitHub Desktop.
A warning engine implemented in π React Final Form
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
const WarningEngine = ({ mutators: { setFieldData } }) => ( | |
// FormSpy lets you listen to any part of the form state you want. | |
// If you provide an onChange prop, FormSpy will not render to the DOM. | |
<FormSpy | |
subscription={{ values: true }} | |
onChange={({ values }) => { | |
setFieldData('firstName', { | |
warning: values.firstName ? undefined : 'Recommended' | |
}) | |
setFieldData('lastName', { | |
warning: values.lastName ? undefined : 'Recommended' | |
}) | |
}} | |
/> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment