Enhancing React components, Composition

Enhancing #ReactJS components, composition:  #JavaScript

  • So, how do you extend a component in React?
  • Well, it’s pretty obvious that the guys @Facebook consider inappropriate to inherit from parent components.
  • Let’s look at alternatives:

    There might be some cases where you have a component which can’t know what its children will be ahead of time (like most of us).

  • For them, React gifts :

    As we can see, receives everything that’s in between the component’s open and closing tag.

  • And just like so, we’ve specialized our component, without creating any inheritance hierarchy!

At Facebook, we use React in thousands of components, and we haven’t found any use cases where we would recommend creating component inheritance hierarchies.

@ReactiveConf: Enhancing #ReactJS components, composition: #JavaScript

Long live to composition, inheritance is dead.

So, how do you extend a component in React?

Well, it’s pretty obvious that the guys @Facebook consider inappropriate to inherit from parent components. Let’s look at alternatives:

receives everything that’s in between the component’s open and closing tag.

Enhancing React components, Composition