autoproxy
A higher-order decorator to automatically proxy properties from the original function to the decorated one so that higher-order components don't get in the way.
How does autoproxy help?
For example, a React component with Redux looks like this:
@Component static NUMBER_OF_SIDES = 4; { ... } { ... }
This component defines a static property called NUMBER_OF_SIDES
and method called bounce
.
Without autoproxy
Without autoproxy, to access these properties we have to write code like this:
Component { return <Box ref= { this_box = component; } />; } { console; this_box; }
See how we need WrappedComponent
and getWrappedInstance()
? This is because the connect
decorator defines Box to wrap the underlying class. As a result Box.NUMBER_OF_SIDES
and this._box.bounce
are both undefined.
With autoproxy
With autoproxy
, the wrapper class automatically proxies the underlying class' properties. Use @autoproxy
to decorate a decorator:
@Component ...
Then you can write Box.NUMBER_OF_SIDES
and this._box.bounce
.