Skip to content

Instantly share code, notes, and snippets.

@brianjlandau
Created August 25, 2015 22:20
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