Created
May 13, 2019 03:31
-
-
Save andycarrell/b731e67dbe81d6e265579c1f829d1c84 to your computer and use it in GitHub Desktop.
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 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