-
Notifications
You must be signed in to change notification settings - Fork 19
Bugs when surrounding HOCs that hoist statics #97
Comments
Thank you for the detailed explanation. Apparently, We'll need to provide a polyfill for older browsers, perhaps something in a similar vein to https://github.com/gaearon/react-proxy/blob/v2.0.8/src/createClassProxy.js#L33-L40 which is more lightweight than Thoughts? |
@matthieuprat sure, that does look like basically the same problem faced by My understanding from looking over those Either way ( So for |
Exactly.
Yes, I think it is, in that unlike So, it's worth trying to use a Are you interested in working on this? Otherwise, I might be able to free up some time this week to tackle this. |
@matthieuprat sure I'll try and get in a PR sometime this week, thanks |
On the current project, we ran into mysterious bugs when placing two
react-apollo
graphql()
HOCs in the samecompose()
chain. Turned out that because each was followed by awithProps()
(iecompose(graphql(), withProps(), graphql(), withProps())
) andgraphql()
useshoist-non-react-statics
to hoist statics, bugs were becausegraphql()
was hoisting the "internal" symbol statics thatrecompact
uses to identify other components as fellow "compactable" Recompact HOCs, sowithProps()
thought thatgraphql()
was another Recompact HOC that it could condense or whatever (at least this is my understanding)So my solution was to fork
recompact
to export the symbols it uses as keys for static properties (opened #95) and forkreact-apollo
to accept a blacklist of keys not to hoist (which can then be passed the exportedrecompact
symbols)However, then this week ran into the same issue using a different HOC (
withNavigation()
fromreact-navigation
) which also hoists statics usinghoist-non-react-statics
. So hoping there's a better approach than trying to get various third-party HOCs to accept a hoist blacklist. This feels at this point like a flaw in the wayrecompact
identifies otherrecompact
HOCs, since it's considered best practice for HOCs to hoist statics (which to my understanding then causes bugs whenever it sits between tworecompact
HOCs), but not sure if there's another mechanism besides statics thatrecompact
could use to identify otherrecompact
HOCs?The text was updated successfully, but these errors were encountered: