Closed huttj closed 6 years ago
I think you can just use it. Decorators are just regular functions.
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.
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!
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?
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…
So, looks like the answer is no, contingent on function decorators being spec'd. Thanks.
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.