Skip to content

title issue with react-18 #35870

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

Closed
1 task done
SimonSiefke opened this issue Apr 4, 2022 · 5 comments · Fixed by #36213
Closed
1 task done

title issue with react-18 #35870

SimonSiefke opened this issue Apr 4, 2022 · 5 comments · Fixed by #36213

Comments

@SimonSiefke
Copy link

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
Platform: linux
Arch: x64
Version: #23-Ubuntu SMP Fri Mar 11 14:54:05 UTC 2022
Binaries:
Node: 17.8.0
npm: 8.5.5
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.1.5-canary.0
react: 18.0.0
react-dom: 18.0.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

With React 18, there is a html comment inside the title tag:

NextJS + React 17:

<title>| abc</title>

NextJS + React 18:

<title>| abc<!-- --></title>

title-issue

Expected Behavior

no html comment is inside the title tag

To Reproduce

https://github.com/SimonSiefke/nextjs-title-issue

@SimonSiefke SimonSiefke added the bug Issue was opened via the bug report template. label Apr 4, 2022
@balazsorban44 balazsorban44 added kind: bug and removed bug Issue was opened via the bug report template. labels Apr 4, 2022
@balazsorban44
Copy link
Member

Probably related facebook/react#24263

@huozhi
Copy link
Member

huozhi commented Apr 4, 2022

Can you try to encode the whole title with jsx? As above issue mentioned, comments are injected intentionally as new constraints for streaming rendering, so if you want to keep it as a single string maybe wrap them together as a jsx child to avoid generating comments

<title>
  {(typeof location !== "undefined" ? location.pathname : "") + " | abc"}
</title>

@agusterodin
Copy link

agusterodin commented Apr 6, 2022

I hope this isn't unnecessary noise but I can confirm this bug. I am experiencing it as well.

@balazsorban44
Copy link
Member

(Upvoting the original issue is usually enough unless more context/info/reproduction is provided in a comment)

Were you able to try out the suggestion from #35870 (comment)?

@kodiakhq kodiakhq bot closed this as completed in #36213 Apr 19, 2022
kodiakhq bot pushed a commit that referenced this issue Apr 19, 2022
There wasn't a strong reason to choose `renderToStream` over `renderToStaticMarkup` for the document wrapper. But due to problems like #35870, we can switch back to the static renderer for now.

Fixes #35870.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <[email protected]>
ivan-aksamentov added a commit to nextstrain/nextclade that referenced this issue May 12, 2022
Upgrades Next.js to version that fixes HTML comment showing up in the browser tab title.

See:
 - vercel/next.js#35870
 - vercel/next.js#36213
 - facebook/react#24263
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants