Skip to content
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

Wrap react components with forwardRef() for DOM access #305

Closed
mikestopcontinues opened this issue Jun 30, 2021 · 3 comments
Closed

Wrap react components with forwardRef() for DOM access #305

mikestopcontinues opened this issue Jun 30, 2021 · 3 comments
Assignees

Comments

@mikestopcontinues
Copy link

Warning: Function components cannot be given refs. Attempts to access this ref will fail.  
Did you mean to use React.forwardRef()?

Currently, it's impossible to pass refs to the react heroicon exports, but this is generally how you would expect to interface with raw SVG, which is what the package exports. Having access to the DOM naturally has a lot of uses. In my current case, I need the ref to smartly position a tooltip.

All it would take to enable this is adding ref: true to the svgr options.

Thanks for your time. 😄

@ekawatani
Copy link

ekawatani commented Sep 1, 2021

+1

In my case, I need to toggle a class name on mousedown and mousup, but there's currently no way to get a reference to the SVG element.

@na0x2c6
Copy link

na0x2c6 commented Nov 13, 2021

+1

In my case, I want to use the icons in combination with tippyjs, which requires a ref:
https://github.com/atomiks/tippyjs-react#component-children

@RobinMalfait RobinMalfait self-assigned this Feb 21, 2022
@RobinMalfait
Copy link
Contributor

RobinMalfait commented Feb 21, 2022

Hey! Thank you for your feature suggestion!
Much appreciated! 🙏

This has been fixed in #614 and will be available in the next release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants