react-auto-binder

1.0.1 • Public • Published

react-auto-binder Build Status

🚀 Auto bind custom methods of your React components

ReactAutoBinder is a higher order component that bind this to all custom methods on your React components (just use ReactAutoBinder(YourComponent) when export it)

Install

NPM

$ npm install react-auto-binder --save

Yarn

$ yarn add react-auto-binder

Usage

import React from 'react'
import ReactAutoBinder from 'react-auto-binder'

class App extends React.Component {
  constructor() {
    super()
    this.state = {
      text: 'default'
    }
  }

  handler() {
    this.setState({ text: this.refs.input.value })
  }

  render() {
    return (
      <div>
        <input type="text" ref="input" onChange={this.handler}/>
        <h1>{this.state.text}</h1>
      </div>
    )
  }
}

export default ReactAutoBinder(App)

License

MIT © Helton Carlos de Souza

Readme

Keywords

none

Package Sidebar

Install

npm i react-auto-binder

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • helton