Higher Order Components

ES6 Class keyword

  • Syntactic sugar for constructor functions
  • Javascript still uses prototypal inheritance
  • Uses the 'constructor' method to create an object
  • Extends allows for sub classing

Constructor

Class

React just uses functions

JSX

Javascript

But wait! It's almost 2016

React + ES2015 = ?

The Component of the Future!

What's the catch?

  • You have to bind "this" manually whenever you add a method
  • No this.isMounted method
  • Lack of mixin support (proposals to fix in ES7)

The HOC Basics

  • Takes a component as an argument
  • Adds additional functionality to the component
  • Returns the augmented component

Higher Order Components

By William Gottschalk

Higher Order Components

  • 455