smooth-react-class-bind
v0.1.1
Published
Quick work to allow for all methods in a React es6 class to have its methods bound to this context
Downloads
2
Maintainers
Readme
smooth-react-class-bind
Synopsis
Quick way to autobind your React ES6 classes w/o having to manually do it in the constructor.
Usage
Please go to npm, and pick up the package.
// your react imports etc..
import autoBindMethods from 'smooth-react-class-bind'
class yourClass extends Component { constructor() { super()
autoBindMethods(this)
}
}
Tests
TODO: this is immensely important, but I just didn't have the time to implement atm. I will revisit shortly.
License
MIT
Optional Arguments
append
@array
allows for binding of mixin methods, just pass in method name.
exclude
@array
pass in method names you do not want bound to the this context
include
@array
pass only the methods you want to bind to this. Using this array will take precedence. If you pass
this in, you will only bind what is in this array - not all the methods on 'this' context.
You might want to target just one method, or two w/o binding a huge array of methods.
How to use?
note: assuming you installed the package and imported it with the name of: autoBindMethods
If you notice any issues, please let me know. Thanks!