Take the following example:
export interface IBaseIconProperties {
path: string;
}
export default class BaseIcon extends React.Component<IBaseIconProperties, any> {
public render() {
return (
<SvgIcon style={{width: 32, height: 32}}>
<path d={this.props.path} />
</SvgIcon>
);
}
}
export default class Foo extends React.Component<any, any> {
public render() {
return <BaseIcon path="/* SVG path for Foo button goes here... */"/>;
}
}
export default class Bar extends React.Component<any, any> {
public render() {
return <BaseIcon path="/* SVG path for Bar button goes here... */"/>;
}
}
This is one way one can do inheritance with React components. Not sure if one can call this inheritance though.
But is there another way? A better way? Maybe through actual inheritance where the BaseIcon class is abstract? Is this possible somehow without over complicating things?