-
Notifications
You must be signed in to change notification settings - Fork 227
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
do not assign ref to stateless function components #377
Comments
facebook/react#4936 for more context. If this check is reliable, 👍 on adding it to all HoCs. |
I'm happy to put together but I immediately was stumped by the choice of where to get the
Take your pick and I'll implement :) |
I looked into whether React has its own function for checking this, but it seems they just inline it: https://github.com/facebook/react/blob/bbd5a78efaf92b7ffcde2a1923112b8931855209/src/renderers/shared/reconciler/ReactCompositeComponent.js#L164 for the best performance. I think we can just use the same logic since HoC's always require a |
sounds good, i'll make a PR |
On React 0.14 I get the following warning when using
connectToStores
on a stateless function component:when doing something like
because you can't specify a ref for a stateless component.See the note at the bottom of https://facebook.github.io/react/docs/reusable-components.html#stateless-functions
Suggested Fix:
Use a check like this:
https://github.com/acdlite/recompose/blob/master/src/packages/recompose/isClassComponent.js
to conditionally pass in the ref here:
https://github.com/yahoo/fluxible/blob/master/packages/fluxible-addons-react/connectToStores.js#L56
The text was updated successfully, but these errors were encountered: