Created
March 22, 2018 15:35
-
-
Save erikras/9607902abb1df1e7991c0bd83abdc4b4 to your computer and use it in GitHub Desktop.
Example of how to use Redux Final Form Listener OnChange
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 WhenFieldChanges = ({ field, becomes, set, to }) => ( | |
<Field name={set} subscription={{}}> | |
{( | |
// No subscription. We only use Field to get to the change function | |
{ input: { onChange } } | |
) => ( | |
<OnChange name={field}> | |
{value => { | |
if (value === becomes) { | |
onChange(to) | |
} | |
}} | |
</OnChange> | |
)} | |
</Field> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment