0

I'm trying to use 2 Material-UI tooltips in the same parent component. Also, I need a custom control for the open and close action of the tooltips. So, I used the open and setOpen states using the UseState hook.

How can I maintain separate states for the 2 tooltips that I use, so that I can differentiate between the respective tooltip's open and close action?

Please help. Hope I made the problem statement clear.

1 Answer 1

2

Create two separate state variables

const MyComponent = () => {
  const [open1, open1Set] = useState(false);
  const [open2, open2Set] = useState(false);
};
Sign up to request clarification or add additional context in comments.

3 Comments

Is this the best answer for this question ?! I have the same problem but actualy I have a list of products and I cannot define their the number in advance ! Is there another solution ?
There's probably a better route when you have n number of items, like in a list. Can you create a new question with a sample of your code and link to it here? I'll try to help
I got the best solution, in case anybody is looking for : stackoverflow.com/questions/69135132/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.