
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
react-auto-bind
Advanced tools
Auto bind methods to their class instance excluding React Lifecycle Methods
Automatically bind methods to their class instance. This is optimized for react. It doesn't bind render and other lifecycle methods.
$ npm install --save react-auto-bind
const autoBind = require('react-auto-bind');
class Unicorn {
constructor(name) {
this.name = name;
autoBind(this);
}
message() {
return `${this.name} is awesome!`;
}
}
const unicorn = new Unicorn('Rainbow');
// Grab the method off the class instance
const message = unicorn.message;
// Still bound to the class instance
message();
//=> 'Rainbow is awesome!'
// While message() would not be bound & would have resulted in
message();
//=> Error: Cannot read property 'name' of undefined
const autoBind = require('react-auto-bind');
class Griffin {
constructor(name) {
this.name = name;
autoBind(this, 'amaze');
}
amaze() {
return `${this.name} is amazing!`;
}
message() {
return `${this.name} is undefined!`;
}
}
const buckbeak = new Griffin('Buckbeak');
// Grab the method off the class instance
const message = buckbeak.message;
const amaze = buckbeak.amaze;
// Still bound to the class instance
amaze();
//=> 'Buckbeak is amazing!'
// Without `autoBind(this)`, the above would have resulted in
message();
//=> Error: Cannot read property 'name' of undefined
Bind methods in self
to their class instance. Returns the self
object.
Type: Object
Object with methods to bind.
Type: Strings
If more than one parameters are passed then only those methods are bound.
FAQs
Auto bind methods to their class instance excluding React Lifecycle Methods
The npm package react-auto-bind receives a total of 510 weekly downloads. As such, react-auto-bind popularity was classified as not popular.
We found that react-auto-bind demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.