Higher-Order Components

Initially, Facebook used mixins to extend the component's functionality. Mixins are basically a way in which we can merge or mix objects. Object.assign is a perfect example of how to do this:

let newObject = Object.assign({}, object_1, object_2);

We've been using this in our Redux reducer function for generating a new state without modifying the original object. One problem of using this as an extension of objects in big apps is the control of the functionality of all those base (mixins) objects. Consider the following example:

let obj_1 = {};obj_1.sayHi = () =>{  console.log('hi from object one')}let obj_2 = {};obj_2.sayBye = () =>{   console.log("bye from object two") }let newObj = Object.assign({}, obj_1, obj_2 ...

Get Build Applications with Meteor now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.