react-refetch icon indicating copy to clipboard operation
react-refetch copied to clipboard

Enable standard use of the ref prop.

Open eyalw opened this issue 9 years ago • 5 comments

Instead of using a string value for the ref property, using the more modern method using the function value will enable regular use of the ref property from the parent of the wrapped component. today: https://github.com/heroku/react-refetch/blob/master/src/components/connect.js#L138 )

suggested: image

eyalw avatar Feb 20 '16 20:02 eyalw

This was lifted directly from react-redux during the fork. I would not be opposed to updating this, but would like to do so in a backward compatible way. It would also be nice if it could continue to work the same way as react-redux (perhaps two PRs are needed?)

ryanbrainard avatar Feb 23 '16 09:02 ryanbrainard

so I guess we check the type of the ref prop (string/func) and act accordingly

eyalw avatar Feb 23 '16 14:02 eyalw

Related: is there any good reason react-redux requires withRef: true be set explicitly? Would it hurt anything to just make the ref always available?

ryanbrainard avatar Feb 23 '16 19:02 ryanbrainard

I can't think of a reason why they require this...

eyalw avatar Feb 23 '16 19:02 eyalw

there is one reason why you don't want withRef to always be true (or even default to true), stateless functional components don't have refs, so if you wrap one of those you can't provide a ref

nfcampos avatar Mar 07 '16 16:03 nfcampos