Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nsisodiya/es6-mixins
ES6 Mixins, Useful for adding Mixin support to React Component when you use ES6 class syntax
https://github.com/nsisodiya/es6-mixins
Last synced: about 1 month ago
JSON representation
ES6 Mixins, Useful for adding Mixin support to React Component when you use ES6 class syntax
- Host: GitHub
- URL: https://github.com/nsisodiya/es6-mixins
- Owner: nsisodiya
- License: mit
- Created: 2016-03-10T10:12:25.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-11T01:27:13.000Z (almost 9 years ago)
- Last Synced: 2024-11-19T15:03:22.096Z (about 2 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# es6-mixins
ES6 Mixins, Useful for adding Mixin support to React Component when you use ES6 class syntax# Installation
```
npm install --save @nsisodiya/es6-mixins
```# Usage
```js
import Mixin from '@nsisodiya/es6-mixins';// The first class to be used as a mixin
class TestMixin1 {
testMethod1() {
console.log('test Method 1 from TestMixin1');
}testMethod2() {
console.log('test Method 2 from TestMixin2');
}
}// The second class to be used as a mixin
class TestMixin2 {
testMethod1() {
console.log('test Method 1 from TestMixin2');
}
}class MainClass {
constructor() {
this.testMethod1(); // outputs 'test Method 1 from TestMixin2' and then 'test Method 1 from TestMixin1' will warn in console about duplicate methods.
}
}Mixin(MainClass, [TestMixin1, TestMixin2]);
new MainClass();
```