Last active
June 17, 2017 01:10
-
-
Save HelveticaScenario/c694c4b3563348a34e728ab3a8eda465 to your computer and use it in GitHub Desktop.
a typesafe curried react input handler using ramda
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
import * as R from 'ramda' | |
const _handleChangeCurried = function<S, P>() { | |
return <K extends keyof S>() => { | |
return R.curry< | |
React.Component<any, S>, | |
K, | |
React.FormEvent<HTMLInputElement>, | |
void | |
>((self, key, e) => | |
self.setState(R.assoc(key, e.currentTarget.value, self.state)) | |
) | |
} | |
} | |
export const handleChangeCurried = <S, P>() => _handleChangeCurried<S, P>()() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment