1 comment

[ 0.18 ms ] story [ 7.9 ms ] thread
I disagree with the premise. In the Article, we construct a button, and make it increasingly more complex by adding props. Eventually, the author states we should stop and leverage children:

"We now have at least 10 optional props and conditions to cover all use cases of all buttons in our application... In react every component gets automatically a prop called children, this prop will be filled with anything you wrap with your component."

The problem with not having a defined interface (for prefixed and/or suffixed icons), is that anytime a developer consumes our button in our application, we can have N variants of it.

If your designers ever want to change, say, the size of the icons inside buttons, now you'll have to adjust that in every instance you use the button, which is the point of having the props abstraction. It gives you an easy way to control all buttons look the same, in one precise location. For this reason, this isn't a helpful application of inversion of control concept.