5 ms·
You have 3 options if you want mixin behaviour: - Use old syntax or explicitly add mixin to prototype - Use composition. A bit annoying, because you have to ma
by lukasm 11y ago
You have 3 options if you want mixin behaviour:
- Use old syntax or explicitly add mixin to prototype
- Use composition. A bit annoying, because you have to make an extra class
class OuterComponent extends React.Component {
render() {
return (
<MixinComponent>
<InnerComponent />
</MixinComponent>
);
}
}
class InnerComponent extends React.Component{}
- wait for decorators (?)
- eskimobloood 11y agoYou can at least try decorators with babel using[1] $ babel --optional es7.decorators or babel.transform("code", { optional: ["es7.decorators"] }); Here[2] is an article that describes how to use it for mixins [1] https://babeljs.io/docs/usage/experimental https://babeljs.io/docs/usage/experimental [2] http://raganwald.com/2015/06/26/decorators-in-es7.html http://raganwald.com/2015/06/26/decorators-in-es7.html