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

Symbol entities like → do not render properly #248

Closed
jdan opened this issue Nov 13, 2016 · 5 comments
Closed

Symbol entities like → do not render properly #248

jdan opened this issue Nov 13, 2016 · 5 comments

Comments

@jdan
Copy link

jdan commented Nov 13, 2016

I first noticed then while trying to add » to my markup, which was rendering as ».

image

Curiously, HMR seems to handle this just fine! I can change my markup to include » and save, and » shows up as expected. A hard refresh, however, results in ».

As a quick repro you can save the following as pages/symbol.js:

import React from "react"
import Head from "next/head"

export default () => <div>
    <Head>
        <meta charset="utf-8" />
    </Head>
    &rarr;
</div>

Note that create-react-app does not seem to suffer from this problem.

@jdan
Copy link
Author

jdan commented Nov 13, 2016

I thought this might be an issue with glamor's renderStatic method, but it seems react-dom/server returns <div>»</div>. So I'm not quite sure what the source of the issue is.

@nkzawa
Copy link
Contributor

nkzawa commented Nov 13, 2016

I can't reproduce the problem. It seems these symbols are correctly rendered to me.

test(async t => {
  const html = await render('/symbol')
  t.true(html.includes('&rarr;'))
})

This test fails, but if I change it to the actual value (), it succeeds.

t.true(html.includes('→'))

@nkzawa
Copy link
Contributor

nkzawa commented Nov 13, 2016

These html special chars are converted to the actual characters when transpiling JSX. And it seems you'd have to set <meta charset="utf8" /> using <Head /> component

facebook/react#1177

@jdan
Copy link
Author

jdan commented Nov 13, 2016

@nkzawa Yes, my apologies, my original repro doesn't seem to point out the issue. I went ahead and modified it.

I am still unable to get the character to display correctly, even with <meta charset="utf-8"> (or "utf8") as pointed out above). Curiously, I see the following in "View source," suggesting that <meta charset> doesn't appear until mount?

<!DOCTYPE html><html><head><title class="next-head">Hello, world! | jordan scales | jordan scales</title><meta class="next-head"/><style>

In DevTools, that <meta> has a charset after the page rehydrates.

@jdan
Copy link
Author

jdan commented Nov 13, 2016

A-ha, charSet not charset! The following fixes my issue:

<Head>
    <meta charSet="utf-8" />
</Head>

No issue here, thanks for your help.

@jdan jdan closed this as completed Nov 13, 2016
@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants