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

    Install

    npm i auto-bind-react

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    3.72 kB

    Total Files

    4

    Last publish

    Collaborators

    • wangsijie