I want to use some abstraction in the creation of my React components. For example:
class AbstractButton extends React.Component {
render() {
return (
<button
onClick={this.props.onClick}
className={this.definitions.className}>
{this.props.text}
</button>
}
}
class PrimaryButton extends AbstractButton {
constructor(options) {
super(options);
this.definitions = {
className: 'btn btn-primary'
};
}
}
class SuccessButton extends AbstractButton {
constructor(options) {
super(options);
this.definitions = {
className: 'btn btn-success'
};
}
}
I don't want to pass these definitions
via props
because I know that these definitions
--in this case the class
--will never change.
Is it an anti-pattern in React? Or is it OK?
My question refers to this altjs issue: this kind of abstraction isn't compatible with @connectToStores
.