FormidableLabs / freactal

Clean and robust state management for React and React-like libs.
MIT License
1.65k stars 46 forks source link

Any intention to support decorators? #87

Closed huttj closed 6 years ago

huttj commented 6 years ago

I'm a fan of MobX, particularly the way that it leverages decorators. Freactal seems very interesting, and I would definitely prefer to use decorators if possible.

gustavohenke commented 6 years ago

I think you can just use it. Decorators are just regular functions.

huttj commented 6 years ago

Oh? I've played with them with Babel, and I was under the impression that the meta stuff was requires, as outlined here.

I'll see if I can just use the functions directly and report back.

gustavohenke commented 6 years ago

That applies to decorators that change an object's properties. If you are decorating a React component, there's nothing to do except wrap it with other components!

huttj commented 6 years ago

I tried to recreate the example with the functions as decorators, and it didn't work. The Babel plugin requires the decorators to be applied to a class or to a method, not to a freestanding function. Is there another plugin that would let me apply them to stateless functional components?

julien-f commented 6 years ago

Function decorators have not yet been specified by a TC39 proposal due to issues with hoisting, for the time being we have to call them as functions…

huttj commented 6 years ago

So, looks like the answer is no, contingent on function decorators being spec'd. Thanks.