3 ms·
The great thing about React is that it's easy to reason about. Devs new to React can quickly come up to speed. When you start decorating React components like t
by steve_taylor 10y ago
The great thing about React is that it's easy to reason about. Devs new to React can quickly come up to speed. When you start decorating React components like this, you're introducing magic and making React code less easy to reason about. I'm not saying that you should avoid this in all cases, but you should consider the pros and cons and be careful. It seems that decorators at the component class level provide a mechanism to bring back mixins for those who want to use ES6 React components with mixins.
- dismantlethesun 10y agoWell I glanced in and saw a decorator for event functions, like a debounce for an onClick. That seems like a whole different thing. Isn't it worth while?
- steve_taylor 10y agoDecorating individual functions probably isn't a bad thing in those cases. The link takes you to only part of the Github repo. Look at the rest of it and you will see various class-level decorators.