Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Element with id 'react-tooltip-base-styles' already exists #1185

Open
gabrieljablonski opened this issue Apr 8, 2024 Discussed in #1184 · 12 comments
Open

[BUG] Element with id 'react-tooltip-base-styles' already exists #1185

gabrieljablonski opened this issue Apr 8, 2024 Discussed in #1184 · 12 comments
Labels

Comments

@gabrieljablonski
Copy link
Member

Discussed in #1184

Check the discussion for more info.

@tonyco97
Copy link

Hi any news?

@gabrieljablonski
Copy link
Member Author

Sorry, haven't had the time yet to investigate this further.

@gabrieljablonski
Copy link
Member Author

Sorry for the delay on getting back to this.

@AYColumbia I tried reproducing the warning with the repo you provided here, but it doesn't happen for me, and the tooltip works normally.

image

Could you provide some more info on this? I'll be able to follow up more promptly now.


@tonyco97 can you provide some info on how you've experienced this issue? Can you try cloning @AYColumbia's repo and seeing if it happens there for you as well?

Here's the repo: https://github.com/AYColumbia/test-tooltip-app

Running npm install followed by npm run startwp should get you there.

@Ti-tanium
Copy link

Any solutions to resolve this?

I'm having the same issue with [email protected].

My project is using react-tooltip, and I have another package that's also using react-tooltip. And I think both of them are trying to inject the react-tooltip base and core style into the html, which causes this warning in console.

I'm seeing 1000+ of them in my console, which is really annoying. Any suggestions?

@gabrieljablonski
Copy link
Member Author

gabrieljablonski commented Jun 28, 2024

@Ti-tanium try using disableStyleInjection='core' (details here) on the tooltip on your main project. Since you have another package using the tooltip, the styles should still be applied.

@Ti-tanium
Copy link

@Ti-tanium try using disableStyleInjection='core' (details here) on the tooltip on your main project. Since you have another package using the tooltip, the styles should still be applied.

Is there a way to disable the injection globally for react-tooltip? Adding the disableStyleInjection for every tooltip is very annoying. Since I might have hundreds of them.

@Ti-tanium
Copy link

Screen Shot 2024-06-28 at 2 25 13 PM

Why do we need this warning? If the style is already injected, why not just skip the injection without giving any warning? Also the check for production if statement is not really working for me (we are probably using prod as the env variable), I'm seeing thousands of warnings in production as well

@gabrieljablonski
Copy link
Member Author

Is there a way to disable the injection globally for react-tooltip?

There's a way described on the docs with environment variables, but that's deprecated. I suggest writing a simple wrapper that sets disableStyleInjection, and just passes through all other tooltip props. Then, you just update the imports from react-tooltip to use your wrapper instead.

Why do we need this warning? If the style is already injected, why not just skip the injection without giving any warning?

We use that as a warning we might be doing something wrong with style injection. We might need to revise the logic, since we hadn't considered your use case, in which you use a package that also uses the tooltip internally.

Also the check for production if statement is not really working for me (we are probably using prod as the env variable)

As you can see on the code, we only check for the production value.

@AYColumbia
Copy link

AYColumbia commented Jun 29, 2024

Sorry for the delay on getting back to this.

@AYColumbia I tried reproducing the warning with the repo you provided here, but it doesn't happen for me, and the tooltip works normally.
...
Could you provide some more info on this? I'll be able to follow up more promptly now.

Hi, I tried some different adjustments the test project but have been unable to reproduce as well. It does still happen with my actual project though so will have to read through the new posts and see if there's anything else I can try. The only thing I can think of is that I may have missed a package that's also loading tooltip that is in my actual project but NOT in the test project. I tried to run that down but haven't found anything yet.

@tonyco97
Copy link

tonyco97 commented Jul 1, 2024

Sorry for the delay on getting back to this.

@AYColumbia I tried reproducing the warning with the repo you provided here, but it doesn't happen for me, and the tooltip works normally.

image

Could you provide some more info on this? I'll be able to follow up more promptly now.

@tonyco97 can you provide some info on how you've experienced this issue? Can you try cloning @AYColumbia's repo and seeing if it happens there for you as well?

Here's the repo: https://github.com/AYColumbia/test-tooltip-app

Running npm install followed by npm run startwp should get you there.

I' ve tried test-tooltip-app and the error does not appear here. In my case, i've a page with react-tooltip which imports a component also containing react tooltip.

I've also tried to use disableStyleInjection but it doesn't work

@AYColumbia
Copy link

I updated my project with multiple components that use react-tooltip and still can't duplicate the issue. It's bewildering.

@tonyco97
Copy link

tonyco97 commented Jul 2, 2024

I updated my project with multiple components that use react-tooltip and still can't duplicate the issue. It's bewildering.

Try to apply some style to both tooltip in both project, one in your project and the in other one in the component that you import in the first one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants