Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-autobind-class-methods

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-autobind-class-methods

Babel plugin that binds every class method to "this" with hot reload support

  • 5.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
543
decreased by-36.71%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-autobind-class-methods

Autobinds "this" to class methods and works with hot reloading.

Compatible with the latest React Hot Loader 3-beta

Installation

   npm install babel-plugin-autobind-class-methods --save-dev 

Example .babelrc:

{
  "presets": ["es2015", "react"],
  "plugins": ["autobind-class-methods"]
}

What it does

Example code:

class Example {
  
  constructor(){
    this.greeting = 'Hello'
  }
  
  greet(){
    console.log(this.greeting)
  }
  
  render(){
    setTimeout(this.greet, 0)
  }
}

const example = new Example()

example.render() // logs out 'Hello', in vanilla js it would log out undefined

Keywords

FAQs

Package last updated on 02 Feb 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc