#tooltip with a custom component
7 messages · Page 1 of 1 (latest)
Hey @fallow apex it works fine for me
https://codesandbox.io/p/sandbox/stoic-andras-tcpgy2?file=%2FApp.jsx%3A10%2C2&utm_medium=sandpack
Can you send a codesanbox repo?
Thanks but if you do something like this :
import React from "react";
import {Tooltip} from "@nextui-org/react";
const TestComponent = ()=> {
return <p>Hover me</p>
}
export default function App() {
return (
<Tooltip content="I am a tooltip">
<TestComponent/>
</Tooltip>
);
}
It’s not ok
Ye it is because the Tooltip will try to find the element or its reference, you need to pass the reference to your custom component
const TestComponent = React.forwardRef((props, ref) => {
return (
<p ref={ref} {...props}>
Hover me
</p>
);
});
Hum, i see. I will try again
I think i was tired when i did the test with this solution. It’s good 🙏