Skip to content

Instantly share code, notes, and snippets.

@ironfroggy
Created November 25, 2015 03:00
Show Gist options
  • Save ironfroggy/9d13b20bcf2a2425cdc3 to your computer and use it in GitHub Desktop.
Save ironfroggy/9d13b20bcf2a2425cdc3 to your computer and use it in GitHub Desktop.
class AutoComponent extends React.Component {
constructor() {
super()
var cls = this.constructor
var methods, methodName
while (cls !== AutoComponent) {
methods = Object.getOwnPropertyNames(cls.prototype)
for (var i in methods) {
methodName = methods[i]
if (methodName.match(/^on[A-Z]/) !== null) {
this[methodName] = this[methodName].bind(this)
}
}
cls = cls.__proto__
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment