@nfq/autobind
v1.1.4
Published
<div id="top"></div>
Downloads
379
Readme
@nfq/autobind
Description: 
The @nfq/autobind package provides a decorator function for automatically binding class methods to the instance of the class. This ensures the correct context (this value) is maintained, especially useful when passing methods as callbacks. It is designed to streamline method binding in JavaScript and TypeScript applications, particularly beneficial in React components and other class-based structures.
Getting started
To install the package locally follow the next steps:
Installation
To install the package run
npm install @nfq/autobindif you are on yarn
yarn add @nfq/autobindor on pnpm
pnpm install @nfq/autobindUsage
The @autobind decorator can be used in class components to ensure that methods are bound to the instance of the class. This is especially useful when passing methods as callbacks.
import {autobind} from '@nfq/autobind';
class MyClass {
@autobind
myMethod() {
// This method is automatically bound to instances of MyClass.
}
}Support
Christoph Kruppe - [https://github.com/ckruppe] - [email protected]
