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

Cannot use React icons with Tooltip directly (forwardRef issue) #63

Open
spotikhanov opened this issue Aug 28, 2024 · 0 comments · May be fixed by #64
Open

Cannot use React icons with Tooltip directly (forwardRef issue) #63

spotikhanov opened this issue Aug 28, 2024 · 0 comments · May be fixed by #64

Comments

@spotikhanov
Copy link

spotikhanov commented Aug 28, 2024

TLDR; Tooltip requires forwardRef for custom react components to work. Icons don't use forwaredRef.

Use-case example (expected):

import CopyIcon from '@gravity-ui/icons/Copy';
import { Tooltip } from '@gravity-ui/uikit';

<Tooltip content={'Copy'}>
    <CopyIcon />
</Tooltip>

But it's not possible now, since icons don't use forwardRef.

The workaround for now is (Icon from uikit has forwadRef):

import CopyIcon from '@gravity-ui/icons/svgs/copy.svg';
import { Tooltip, Icon } from '@gravity-ui/uikit';

<Tooltip content={'Copy'}>
    <Icon data={CopyIcon} />
</Tooltip>

But it requires something like svgr for svg import to work and is more cumbersome.

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

Successfully merging a pull request may close this issue.

1 participant