# smooth-react-class-bind

> Quick work to allow for all methods in a React es6 class to have its methods bound to this context

Latest version **0.1.1** (published 2016-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install smooth-react-class-bind
pnpm add smooth-react-class-bind
yarn add smooth-react-class-bind
bun add smooth-react-class-bind
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2016-05-29 |
| First published | 2016-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dean Sacramone |
| Maintainers | deansacramone |
| Keywords | bind, es6-bind, autobind, auto bind, bind React methods, React autobind, React Bind, React ES6 Bind, autobind class |

## Links

- npm: https://www.npmjs.com/package/smooth-react-class-bind
- Repository: https://github.com/dsacramone/smooth-react-class-bind
- Homepage: https://github.com/dsacramone/smooth-react-class-bind#readme
- Issues: https://github.com/dsacramone/smooth-react-class-bind/issues
- npm.io page: https://npm.io/package/smooth-react-class-bind

## Recent versions

- 0.1.1 (latest) — 2016-05-29

## 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.
<ul>
    <li> Import package at top of your page
    <li> Follow instructions below
</ul>
<pre><code>

// your react imports etc..

import autoBindMethods     from 'smooth-react-class-bind'

class yourClass extends Component {
    constructor() {
        super()

        autoBindMethods(this)
    }
}

</code></pre>

## 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
<pre><code>
*I want to bind all methods in my React Class:

constructor() {
    super()
    autoBindMethods(this)
}


*I want to bind only the method 'getProducts'

constructor() {
    super()
    autoBindMethods(this, {include: ['getProducts']})
}


*I want to exclude only the method 'getProducts', from binding all other methods

constructor() {
    super()
    autoBindMethods(this, {exclude: ['getProducts']})
}


</code></pre>

If you notice any issues, please let me know. Thanks!

---
_Source: https://npm.io/package/smooth-react-class-bind · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
