bindable-component
v1.1.0
Published
Expose extendable react component for binding handlers
Downloads
2
Maintainers
Readme
bindable-component
Exposes BindableComponent
to easily bind component methods for use as handlers within react.
Also provides BaseComponent
, with the only difference being the inclusion of the PureRenderMixin
.
Installation
npm install --save bindable-component
Usage
import { BindableComponent } from 'bindable-component';
// Aternatively
// import { BaseComponent } from 'bindable-component';
class MyComponent extends BindableComponent {
constructor() {
super();
this._bind('onClick', 'onChange');
}
onClick() {
// Will have proper this scope
}
onChange() {
// Will have proper this scope
}
render() {
return (
<form>
<input onChange={this.onChange} />
<button onClick={this.onClick}>submit</button>
</form>
);
}
}
License
See LICENSE.