react-use-caret-position icon indicating copy to clipboard operation
react-use-caret-position copied to clipboard

Consumer should pass in the `ref`

Open melanieseltzer opened this issue 3 years ago • 2 comments

We currently create the ref inside the hook and expose it to the consumer.

This works fine but also isn't very flexible. If the consumer wants to use another ref on the same element, they would have to merge the ref from our hook + the other one when attaching it to the element.

We should instead have the consumer pass the React.RefObject<HTMLInputElement | HTMLTextAreaElement> into the hook.

This would be a breaking change so we'd need to create a v2.0.0 release.

melanieseltzer avatar Oct 14 '22 16:10 melanieseltzer

Hey @melanieseltzer, would love to contribute to this.

Will you please assign this to me ?

logicalahara avatar Oct 15 '22 09:10 logicalahara

It's all yours, @logicalahara 😄 Thanks for the help!

For reference/a starting point, my original implementation when initially developing this hook (way back before releasing v1.0.0) had the ref getting passed in.

melanieseltzer avatar Oct 15 '22 15:10 melanieseltzer