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

Remove warning about styles already being injected #1203

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/utils/handle-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ function injectStyle({
const { insertAt } = ref

if (document.getElementById(id)) {
// this should never happen because of `injected[type]`
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.warn(
`[react-tooltip] Element with id '${id}' already exists. Call \`removeStyle()\` first`,
)
}
// this could happen in cases the tooltip is imported by multiple js modules
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this even worth investigating further?

There seems to be no downside to just skipping injecting styles if they're already present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree, the issue is inject the styles multiple times, but there's no issue if we only ignore it if it's already injected into the website

return
}

Expand Down
Loading