
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
class-decorators
Advanced tools
Provides mixin support through es2015 decorators. @mixin will assign mixins in the order they are provided from left to right.
npm i class-decorators -S
// myMixins.js
import request from 'request';
export const Readable = {
get() {
return request.get();
},
head() {
return request.head();
}
};
export const Writeable = {
post() {
return request.post();
},
put() {
return request.put();
},
patch() {
return request.patch;
},
delete() {
return request.delete();
}
};
// api.js
import {mixin, override} from 'class-decorators';
import {Readable, Writable} from './myMixins';
@mixin(Readable, Writable)
class Api {
get() {
return 'this will be overwritten by Readable.get';
}
@override
post() {
return 'this will not be overwritten due to @override';
}
}
@cascadereact-class-mixin will automatically decorate the following methods with @cascade.
render
getInitialState
getDefaultProps
propTypes
mixins
statics
displayName
componentWillMount
componentDidMount
componentWillReceiveProps
shouldComponentUpdate
componentWillUpdate
componentDidUpdate
componentWillUnmount
Using decorators to add mixins will cause your component lifecycle methods to be overwritten by methods used in the mixins. Decorating your methods with @cascade will call the mixin functions first in the order they were applied. Mixins are not required to be decorated with @cascade since decorating the component method will apply to all methods. Returns from all methods will be returned in an array in the order the methods were called.
import {Component} from 'react';
const MyComponentMixin = {
componentDidMount() {
...
// This function will be called just before the `componentDidMount`
// method on the class this mixin is applied to
}
}
const MyOtherComponentMixin = {
componentDidMount() {
...
}
}
@mixin(MyComponentMixin, MyOtherComponentMixin)
class MyComponent extends Component {
@cascade
componentDidMount() {
// When this method is called, the order of function calls will be
// 1) MyComponentMixin.componentDidMount()
// 2) MyOtherComponentMixin.componentDidMount()
// 3) MyComponent.componentDidMount()
}
}
FAQs
Adds mixin support to es6 classes using decorators
We found that class-decorators 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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.