1

I'm using ReasonML.

I would like to create a tooltip element. It should wrap a React.element and provide tooltip functionality, triggered by mouseevents.

But I would not like it to appear in the DOM at all, because that can disrupt the layout. I've tried using display: contents, but some CSS rules will still be disrupted.

Is it possible to add mouseevent listeners to the children:React.element object either through adding to its properties or getting a reference and adding it through that?

  • 1
    You can use [`cloneElement`](https://rescript-lang.org/docs/react/latest/elements-and-jsx#cloning-elements) to add properties to children. Your question otherwise doesn't make a whole lot of sense. Instead of using terms you have a poor understanding of, you might want to consider explaining what you want at a higher level, and/or use examples to illustrate. – glennsl Nov 09 '21 at 11:24
  • Sorry, should have spent some more time writing the question. cloneElement worked like a charm, thank you. – user3189932 Nov 09 '21 at 11:50

0 Answers0