Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1012 Bytes

README.md

File metadata and controls

51 lines (36 loc) · 1012 Bytes

bindable-component

https://travis-ci.org/swhite24/bindable-component.svg?branch=master

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.