Skip to content

Instantly share code, notes, and snippets.

@erikras
Created March 22, 2018 15:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save erikras/9607902abb1df1e7991c0bd83abdc4b4 to your computer and use it in GitHub Desktop.
Example of how to use Redux Final Form Listener OnChange
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