Skip to content

Instantly share code, notes, and snippets.

@brianjlandau
Created August 25, 2015 22:20
Show Gist options
  • Save brianjlandau/5e270f2aea1d5bd9f9f3 to your computer and use it in GitHub Desktop.
Save brianjlandau/5e270f2aea1d5bd9f9f3 to your computer and use it in GitHub Desktop.
Allows you to abstract out the common behaviour of wanting to create an onChange function that just sets the Colonel Kurtz value based on the input value.
/**
* SharedOnChange Colonel Kurtz Mixin
* Allows you to abstract out the common behaviour of wanting to
* create an onChange function that just sets the CK value
* based on the input value.
*/
var React = require('react')
module.exports = {
_onChangeFor(fieldName) {
return this._sharedOnChange.bind(this, fieldName)
},
_sharedOnChange(fieldName, e) {
this.props.onChange({
[fieldName]: e.currentTarget.value
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment