Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Composition over inheritance code example
// Ugly way
const Text = () => {
// ... some implementation ...
}
class H1 extends Text {
// ... override some implementation ...
}
class H2 extends H1 {
// ... override some implementation ...
}
// Best way
const Text = () => {
// ... some implementation ...
}
const H1 = props => <Text tag="h1" {...props} />;
const H2 = props => <Text tag="h2" {...props} />;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment