auto-bind-react

1.0.0 • Public • Published

auto-bind-react

Automatically bind methods to their class instance for React

Install

npm install auto-bind-react

Usage

import React, {Component} from 'react';
import AutoBind from 'auto-bind-react';
 
export default class Hello extends Component {
    constructor() {
        super();
        AutoBind(this);
        this.state = {
            slogan: 'I am so cool!'
        };
    }
    say() {
        alert(this.state.slogan);
    }
    render() {
        return (
            <div onClick={this.say}>
                Click me to say hello!
            </div>
        );
    }
}

License

MIT © Wang Sijie

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    1

Package Sidebar

Install

npm i auto-bind-react

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.72 kB

Total Files

4

Last publish

Collaborators

  • wangsijie