Comments (5)
Hey thanks for the nice note :)
I think what you're running into is React's auto-escaping by default? There's some ways around that documented here: https://shripadk.github.io/react/docs/jsx-gotchas.html -- does that help?
from react-head.
Hi, @tizmagik – Sorry for the delayed response. Yes, I read through that. Unfortunately, I don't see a workaround for attributes. dangerouslySetInnerHTML
is the closest... but isn't for attributes.
Unless I missing something obvious... Work correctly in the browser, just not with renderToStaticMarkup
.
from react-head.
Oh interesting, hmm... do you know if the problem is specific to react-head or to renderToStaticMarkup?
from react-head.
I've got something going on with my GitHub notifications because I never get a notice when you respond...
Looks like it's an issue with ReactDOM's renderToStaticMarkup
. Here's a runkit:
http://runkit.com/joshuatoenyes/reactdom-ampersand-test
Which leads me back to the workaround... Seem's like this is definitely a JSX "gotcha."
So unless there's some known workaround that I'm not aware of (which seems like the case), I think the only solutions are:
a) not include ampersands in URL's (what I'm doing now)
b) build a custom React renderer for React Head that doesn't escape in SSR
I'll fix my notifications :) cheers.
from react-head.
It looks like React Helmet can allow special characters in generated SSR output by flipping the encodeSpecialCharacters
property to false
.
They're manually building the tag strings:
https://github.com/nfl/react-helmet/blob/420810c644f94c3743f7b088321dbd62a8037b7b/src/HelmetUtils.js#L514
Obviously a more complex approach than React Head takes.
I'm going to close this issue by noting for posterity that React Head doesn't support this particular corner case since all rendered components for SSR are piped through React and therefore subject to React's JSX escaping rules.
Thanks!
from react-head.
Related Issues (20)
- Link canonical cascade HOT 1
- Expose HeadTag? HOT 2
- Question: Does it work without ssr for SEO, on fb and twitter ? HOT 1
- Children prop type missing in HeadProvider HOT 7
- Is this library still maintained? HOT 1
- Suggestion: use renderToStaticMarkup instead of renderToString HOT 4
- Some tags not collected HOT 4
- Invariant failed in HeadTags HOT 9
- Development server not working HOT 2
- does not support ie9? HOT 2
- Proposal: headTagsToElement(headTags) HOT 1
- Element.remove() not supported in IE HOT 3
- Document usage with SSR streaming HOT 3
- TypeScript support HOT 3
- react-head supports meta update on lazy load HOT 3
- itemProp support on <Meta /> HOT 1
- canonical link is repeated HOT 1
- Title component doesn't override default <title> tag provided via HTML template HOT 10
- RFC: Managing tags without extra markup HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-head.