Skip to content

fix: dedupe theme core <link> in useThemeCore#262

Open
arbrandes wants to merge 1 commit into
openedx:mainfrom
arbrandes:arbrandes/fix-double-injection
Open

fix: dedupe theme core <link> in useThemeCore#262
arbrandes wants to merge 1 commit into
openedx:mainfrom
arbrandes:arbrandes/fix-double-injection

Conversation

@arbrandes
Copy link
Copy Markdown
Contributor

Description

Under React StrictMode the useThemeCore effect ran twice on mount and appended a second core stylesheet after the variant <link>, which let core :root declarations override the variant for any custom properties they happened to share. The effect now looks for an existing link[data-theme-core="true"] first: if its href matches the target URL it reuses it, and if the URL has changed it removes the stale link before appending the new one. This mirrors the dedup pattern already used by useThemeVariants.

Closes #261

LLM usage notice

Built with assistance from Claude.

Under React StrictMode the effect ran twice on mount and appended a
second core stylesheet after the variant link, letting core :root
declarations win over variants that shared the same custom properties.

Closes openedx#261

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useThemeCore double-injects core <link> under StrictMode, can override variant :root tokens

1 participant