Socket
Socket
Sign inDemoInstall

babel-autobind

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-autobind

it binds methods to its class prototype + Compatible with stub/spy used on unit-test frameworks (Sinon.Js, enzyme,...so on) + Can be integrated with 3rd party decorators (like @autobind decorator)


Version published
Maintainers
1
Install size
6.52 kB
Created

Readme

Source

Build Status Coverage Status

Overview

it binds methods to its class prototype + Compatible with stub/spy used on unit-test frameworks (Sinon.Js, enzyme,...so on) + Can be worked together with other 3rd party decorators (like autobind-decorator)

Basic Example :

import {Autobind} from 'babel-autobind';

@Autobind
 class MyComponent extends React.Component {

 }
 export default MyComponent;

Or

import {Autobind} from 'babel-autobind';

 class MyComponent extends React.Component {

 }
 export default Autobind(MyComponent);

@Autobind decorator is more elegant than Autobind(...) function , However , Autobind(...) function is overloaded . Indeed, it accepts 2nd argument to rename the class after binding.

Example
import {Autobind} from 'babel-autobind';

 class MyComponent extends React.Component {

 }
 export default Autobind(MyComponent,'YourComponent');

From release 0.3.3, it is possible to rename the class name from decorator too.

Example
import {Autobind} from 'babel-autobind';

@Autobind('YourComponent')
 class MyComponent extends React.Component {

 }
 export default MyComponent;

Keywords

FAQs

Last updated on 01 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc