Do you ever find yourself frustrated with all the boilerplate and repetitive code in React components? Frequent use of patterns make components long-winded, hard to reason about, and difficult to maintain. And with mixins no longer supported in ES6 components, there is no longer any obvious solution!
This became a problem while writing Memamug. Without mixins, the code gradually evolved a bunch of annoying patterns, including:
- passing unknown props through to child nodes
- writing out long CSS class names
- merging internal callbacks with those specified on
props
But there is a solution: Higher-Order Components. And seeing how helpful I’ve found them, it is only natural that I want to spread the word!