react-icons / react-icons/react-icons
Use `forwardRef` with `IconBase`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.7k
- Forks
- 809
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
Chakra UI provides a Tooltip component that displays a tooltip when the component's children are hovered. In order to make this functionality work, we depend on the outermost child of Tooltip accepting a ref. Since IconBase does not forward refs, we are unable to make Tooltip work correctly if the outermost child is a react-icons icon.
See chakra-ui/chakra-ui#683 for a related issue on our end.
Describe the solution you'd like
Integrate React.forwardRef into IconBase so that icons generated by react-icons can accept a ref, increasing their flexibility and reusability.
See https://reactjs.org/docs/forwarding-refs.html#forwarding-refs-to-dom-components for more details.
Describe alternatives you've considered
The only solution we have for our users is that they should wrap their react-icons icons with a component that forwards refs if they would like to wrap the icon with Tooltip.
Additional context
This would be a breaking change. https://reactjs.org/docs/forwarding-refs.html#note-for-component-library-maintainers
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating IconBase and the generated icon components, then review React's forwardRef guidance linked in the issue. Confirm how refs are currently handled and identify the existing checks around icon rendering. Done means generated react-icons components accept refs for consumers such as Chakra UI's Tooltip, with the breaking-change impact accounted for.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100