Skip to content

Instantly share code, notes, and snippets.

@pavel-lens
Created April 19, 2017 16:12
Show Gist options
  • Save pavel-lens/5658cb8e65d9c06bcec12695d0279169 to your computer and use it in GitHub Desktop.
Save pavel-lens/5658cb8e65d9c06bcec12695d0279169 to your computer and use it in GitHub Desktop.
createHandleChange(callback) {
// This has to be a ES5 function, because we need to access its `arguments`
return (function() {
// don't run for children that has no onChange prop
if (!callback) {
return
}
// set touched to true so we can re-render active Apply/Revert buttons
if (!this.state.touched) {
this.setState({ touched: true })
}
// Call the original callback
callback.apply(null, arguments)
}).bind(this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment