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: <title> element duplicates and <link> and <style> doesn't move to <head> element #32562

Open
NagayamaToshiaki opened this issue Mar 10, 2025 · 1 comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@NagayamaToshiaki
Copy link

React version: [email protected]

Steps To Reproduce

  1. Make the root component
  2. Load another element that includes either <title>, <link> or <style>.

Link to code example: https://stackblitz.com/edit/vitejs-vite-e847s61k

The current behavior

  1. <title> element inside the element is added above the existing one. thus there are (more than) 2 <title>s.
  2. <link> and <style> stay at the component you wrote.

The expected behavior

According to the official doc, "When React renders this component, it will see the <title> and tags, and automatically hoist them to the section of document.".

  1. Existing <title> will be overridden by the one shown by the element. ( or should they have a rule for multiple elements that have <title>? Parhaps LIFO rule is intuitive enough) <title> should be only 1 element to follow HTML spec.
  2. <link> and <style> should be inside <head> element.
@NagayamaToshiaki NagayamaToshiaki added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 10, 2025
@viraj123ab
Copy link

Remove <React.StrictMode> if it's causing double renders in development. In production then won't be any problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants