I have the next component that is created using React Js:
const Button = ({ children }) => {
return <button className="IconButton">{children}</button>;
};
const TooltipDemo = () => {
return (
<Tooltip.Provider>
<Tooltip.Root>
<Tooltip.Trigger asChild>
<Button>
<PlusIcon />
</Button>
</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Content className="TooltipContent" sideOffset={5}>
Add to library
<Tooltip.Arrow className="TooltipArrow" />
</Tooltip.Content>
</Tooltip.Portal>
</Tooltip.Root>
</Tooltip.Provider>
);
};
export default TooltipDemo;
The code display the next issue in the console:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
If i use a simple button tag without using Button component the the error disappear.
Why the isuue appear and how to solve it without using forward ref as many answers suggests?
demo: https://codesandbox.io/s/dry-bird-u051ih?file=/App.js:153-775