Skip to content

Instantly share code, notes, and snippets.

@ranbena
Created December 27, 2018 18:26
Show Gist options
  • Save ranbena/c0c1f7ff3ef86d60bf6b0117202bb91b to your computer and use it in GitHub Desktop.
Save ranbena/c0c1f7ff3ef86d60bf6b0117202bb91b to your computer and use it in GitHub Desktop.
React inheritance
class Label extends React.Component{
constructor(props){
super(props);
this.className='plain-label';
}
render(){
return <span className={this.className}>
{this.props.children}
</span>
}
}
class SuccessLabel extends Label{
constructor(props){
super(props);
this.className = this.className + ' success-label';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment