React now supports the use of ES6 classes as an alternative to React.createClass()
.
React's concept of Mixins, however, doesn't have a corollary when using ES6 classes. This left the community without an established pattern for code that both handles cross-cutting concerns and requires access to Component Life Cycle Methods.
In this gist, @sebmarkbage proposed an alternative pattern to React mixins: decorate components with a wrapping "higher order" component that handles whatever lifecycle methods it needs to and then invokes the wrapped component in its render()
method, passing through props
.
While a viable solution, this has a few drawbacks:
- There's no way for the child component to override functionality defined on the higher order component.