https://github.com/nitin42/component-bind
Binds all the class methods to their instances in your component.
https://github.com/nitin42/component-bind
react react-components
Last synced: 10 months ago
JSON representation
Binds all the class methods to their instances in your component.
- Host: GitHub
- URL: https://github.com/nitin42/component-bind
- Owner: nitin42
- Created: 2017-01-24T17:26:27.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-01T17:59:51.000Z (almost 9 years ago)
- Last Synced: 2025-02-22T11:02:42.682Z (10 months ago)
- Topics: react, react-components
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# component-bind
[](https://travis-ci.org/nitin42/set-bind)
> Binds all the class methods to their instances in your components.
## Details
* Polyfill for the implementations that do not natively support ***bind()***.
* Not necessarily binds the lifecycle hooks to the class instance.
## Install
```
npm install --save cmp-bind
```
## Usage
```javascript
const binder = require('cmp-bind');
class App {
constructor(name) {
this.name = name || null,
binder(this); // Call here
};
component() {
return `${this.name}`
}
error() {
return `I am not a comp.`;
}
}
const child = new App('Component');
const logger = child.component;
console.log(logger()); // Component
const error = child.error;
console.log(error()) // I am not a comp.
```
## Tests
```
npm run test
```
## Contributing
Add unit tests for any new or changed functionality.
## License
ISC