News for hackers. Stuff that matters.
Re:Show HN: React-decoration – A collection of decorators fo... by STRML on Saturday October 29, 2016 @12:23PM (#12824660)
Nice work. But perhaps you meant to link to https://github.com/mbasso/react-decoration/tree/master/docs instead? The releases page only shows a single release and two decorators.

It is also worth noting that the decorator syntax is still not final, and using it with Babel 6 requires https://github.com/loganfsmyth/babel-plugin-transform-decora.... More details on the decorator deprecation is in that repo.

Re:Show HN: React-decoration – A collection of decorators fo... by pault on Saturday October 29, 2016 @05:33PM (#12826520)
I don't see anything here, with the exception of the debounce decorator, that isn't just an excuse to use a decorator for some reason. All of the examples can be implemented without decorators with the same amount of complexity and clarity.
Re:Show HN: React-decoration – A collection of decorators fo... by paulftw on Sunday October 30, 2016 @04:31AM (#12828711)
That's what I thought, and there are lodash & underscore to do twenty different flavours of debounce. However, stuff like @killEvent and @stopPropagation does make sense.
Re:Show HN: React-decoration – A collection of decorators fo... by steve_taylor on Sunday October 30, 2016 @05:58AM (#12828940)
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.
Re:Show HN: React-decoration – A collection of decorators fo... by dismantlethesun on Sunday October 30, 2016 @06:36AM (#12829052)
Well 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?

Re:Show HN: React-decoration – A collection of decorators fo... by steve_taylor on Sunday October 30, 2016 @07:50AM (#12829284)
Decorating 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.
Re:Show HN: React-decoration – A collection of decorators fo... by hokkos on Saturday October 29, 2016 @03:03PM (#12825693)
The examples on the main page don't look very compeling :

@autobind onClick() {} is equivalent to : onClick = () => {}

@extractValue onChange(value) {} is equivalent to : onChange({value}) {}

It longer, less efficient, less understandable.

Re:Show HN: React-decoration – A collection of decorators fo... by mhluongo on Saturday October 29, 2016 @03:56PM (#12825999)
The main docs page has better examples.
Re:Show HN: React-decoration – A collection of decorators fo... by maxthegeek1 on Saturday October 29, 2016 @08:14PM (#12827293)
Decorator's shouldn't be a part of javascript when function composition serves the same purpose without adding additional syntax.
Re:Show HN: React-decoration – A collection of decorators fo... by acjohnson55 on Sunday October 30, 2016 @01:05AM (#12828262)
To play Devil's advocate, function composition can accomplish literally anything that's conputable, and principle of least power would suggest that having specific and limited syntax for common patterns is productive.

If Javascript continues to admit statement-based syntax, I think decorators are appropriate, because they allow the functional decorator pattern to be applied to function (and method, and class) declarations.

Re:Show HN: React-decoration – A collection of decorators fo... by olalonde on Sunday October 30, 2016 @01:35AM (#12828327)
Most of the things that were introduced in ES6 were already possible without adding additional syntax (classes, arrow functions, etc.).
Re:Show HN: React-decoration – A collection of decorators fo... by dismantlethesun on Sunday October 30, 2016 @06:37AM (#12829056)
Function composition is so common it deserves its own syntax.
Re:Show HN: React-decoration – A collection of decorators fo... by acjohnson55 on Sunday October 30, 2016 @12:56AM (#12828240)
This reminds me of https://github.com/acdlite/recompose, although the latter seems a bit more useful at first glance.