-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Higher order component should provide access to original #26
Comments
That's a sensible problem indeed. Do you know if any library is currently coping with this problem and how they might solve it? |
Unfortunately, no. |
It was discussed in acdlite/flummox#173 function statics(a) {
return b => Object.assign(b, a)
}
@statics({
willTransitionTo(transition) {
transition.abort();
}
})
@connect({
someStore: (store) => ({
someProp: store.getSomeProp()
})
})
export default class SomeRoute{
render() {
return <div>{this.props.someProp}</div>
}
} I've tried the same approach with Baobab-React and everything works fine. |
This seems a nice solution @ivan-kleshnin. I don't know if this already exist but I would love to see a tiny lib pack some of the more useful react-related decorators such as this |
Never met one. I will share a link if find. |
I know this is old, but just incase anyone else was looking for a library: This part of the react-docs points to a library called hoist-non-react-static, and it is used by react-redux's |
Hello @prescottprue. I don't remember if my HOC do this work properly. Do you want to open a PR? |
After this
and exposing proxied
Foo
there is no reference to originalFoo
. Since wrapper does not expose any method of original and does not provide a link to original, a bunch of useful techniques and strategies that were available with mixins become blocked. For example, data loading strategy described at Yomguithereal/baobab#170 is blocked because no property of original component can pass through this proxy.Decorators use higher-order component (HOC) approach and in HOC that's the only place where original component is used:
I believe that HOC should still keep a link to a wrapped (original) component somehow.
This should be as easy as adding
in both
function root
andfunction branch
.The text was updated successfully, but these errors were encountered: