Skip to content

Instantly share code, notes, and snippets.

@andycarrell
Created May 13, 2019 03:31
Show Gist options
  • Save andycarrell/b731e67dbe81d6e265579c1f829d1c84 to your computer and use it in GitHub Desktop.
Save andycarrell/b731e67dbe81d6e265579c1f829d1c84 to your computer and use it in GitHub Desktop.
const withFormikField = F => {
const HoC = ({ name, onBlur, onChange, ...rest }) => {
const handleChange = value => onChange({ target: { name, value } });
const handleBlur = () => onBlur({ target: { name } });
return <F {...rest} onChange={handleChange} onBlur={handleBlur} />;
};
return HoC;
};
const SelectForFormik = withFormikField(Select);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment